| |

VerySource

 Forgot password?
 Register
Search
View: 770|Reply: 2

How to use log4j? Hope prawn gives an example, thank you

[Copy link]

2

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 Invalid IP Address

Post time: 2020-1-28 16:20:01
| Show all posts |Read mode
I always use System.out.println ("***");
This test is done, but this is very troublesome, I hope the prawns give me an example, more details, thanks
Reply

Use magic Report

0

Threads

10

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-3-1 16:30:01
| Show all posts
Copy a log4j or write a log4j to WEB-INF / classes
log4j content such as:
-------------------------------------------------- ----------------------------------
log4j.rootCategory = DEBUG, stdout, R

# Set the level to DEBUG if you want to log all SlideExceptions (some of them aren't errors)
log4j.category.org.apache.slide.common.SlideException = FATAL

#########################################
log4j.appender.stdout = org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout = org.apache.log4j.PatternLayout

# Pattern to output the caller's file name and line number.
# log4j.appender.stdout.layout.ConversionPattern =% 5p [% t] (% F:% L)-% m% n
# log4j.appender.stdout.layout.ConversionPattern =% 4p [% t]% c-% m% n
log4j.appender.stdout.layout.ConversionPattern = [% t]% -5p% -20c {2}-% m% n

log4j.appender.R = org.apache.log4j.RollingFileAppender
log4j.appender.R.File = logger.log

log4j.appender.R.ImmediateFlush = true

log4j.appender.R.MaxFileSize = 100KB
# Keep one backup file
log4j.appender.R.MaxBackupIndex = 1

log4j.appender.R.layout = org.apache.log4j.PatternLayout
# log4j.appender.R.layout.ConversionPattern =% p% t% c-% m% n
# log4j.appender.R.layout.ConversionPattern =% 4p [% t]% c-% m% n
log4j.appender.R.layout.ConversionPattern =% d {ABSOLUTE} [% t]% -5p% -30c {3}% x-% m% n




Use as:
import org.apache.log4j.Logger;
Then you need to write the following sentence at the beginning of the class
private final static Logger log =
Logger.getLogger (ClassName.class); // Note that what is written here is the class name of the current class.
So you have a log object called log, this log has the following centralized usage
log.info (); // General information
log.debug (); // Debug information
log.error (); // Error message
log.warn (); // Warning information
log.fatal (); // fatal error message
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-4-15 14:30:01
| Show all posts
Thank you upstairs, I also want to know more details
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list