Application of Log4j in JSP Project

xiaoxiao2021-03-06  41

WEB-INF / CLASSES Create a file: Log4j.properties, the content is as follows:

log4j.rootCategory = WARN, A1, Rlog4j.appender.A1 = org.apache.log4j.ConsoleAppenderlog4j.appender.A1.layout = org.apache.log4j.PatternLayout # Print the date in ISO 8601 formatlog4j.appender.A1.layout. ConversionPattern =% D [% T]% -5p% C -% M% N

# R is The rollingfileappender That Outputs to a rolling log # file caled rolling_log_file.log.

Log4j.Appender.r = org.apache.log4j.rollingfileAppenderlog4j.Appender.r.file = log4j.log

# Define a pattern layout for the file. # For more information on conversion characters (i.e. d, p, t, c, l, m, n) # please see the patternLayout Class of the log4j API.

Log4j.rapnder.r.Layout = org.apache.log4j.patternLayoutLog4j.Appender.r.Layout.conversionPattern = [DATE]% D {DATE}% n [priority]% p% n [ndc]% x% n [thread ]% T% N [category]% C% N [location]% L% N [Message]% M% N% N

# Set the max size of the file and the number of backup files

Log4j.Appender.r.maxfilesize = 100kblog4j.appender.r.maxbackupindex = 1

Web.xml content is as follows:

Log4j no description com.apache.jakarta.log4j.log4jinit < PARAM-NAME> LOG4J /web-inf/log4j.properties

Place log4j-1.2.8.jar in a web-inf / lib directory. Can be used

转载请注明原文地址:https://www.9cbs.com/read-116290.html

New Post(0)