Log4j Best Practice All-Energy Profile

zhaozj2021-02-16  99

Hereinafter, the log4j profile implements the output to the console, file, rollback file, send log mail, output to database log table, custom label, etc.

Log4j.rootlogger = Debug, console, a1,

IM # debug, console, file, rolling_file, mail, database

Log4j.addivity.org.apache = true

###################

# Console Appender

###################

Log4j.Appender.console = org.apache.log4j.consoleappender

Log4j.Appender.threshold = Debug

Log4j.appender.console.target = system.out

Log4j.Appender.console.Layout = Org.apache.log4j.patternlayout

Log4j.Appender.console.Layout.conversionPattern = [framework]% D -% C -% - 4R [% T]% -5p% C% X-% M% N

# Log4j.Appender.console.Layout.conversionPattern = [start]% d {date} [date]% N% P [priority]% N% x [NDC]% N% T [thread] N% C [category]% N% M [Message]% N% N

#####################

# File appender

#####################

Log4j.Appender.file = org.apache.log4j.fileappender

Log4j.Appender.file.file = file.log

Log4j.Appender.File.Append = false

Log4j.Appender.File.Layout = Org.apache.log4j.patternlayout

Log4j.Appender.File.Layout.conversionPattern = [framework]% D -% C -% - 4R [% T]% -5p% C% X-% M% N

# @ Use this Layout for logfactor 5 Analysis

################################

# Rolling file

################################

Log4j.Appender.rolling_file = org.apache.log4j.rollingfileAppender

Log4j.Appender.rolling_file.threshold = error

Log4j.Appender.rolling_file.file = rolling.log

Log4j.Appender.rolling_file.append = true

Log4j.Appender.rolling_file.maxfilesize = 10kb

Log4j.Appender.rolling_file.maxbackupindex = 1

Log4j.Appender.rolling_file.Layout = Org.Apache.log4j.patternlayout

Log4j.Appender.rolling_file.Layout.conversionPattern = [framework]% D -% C -% - 4R [% T]% -5p% C% X -% M% N

####################

# Socket Appender

################### log4j.Appender.socket = org.apache.log4j.rollingfileappender

Log4j.Appender.socket.remotehost = localhost

Log4j.Appender.socket.port = 5001

Log4j.Appender.socket.locationinfo = TRUE

# Set up for log facilt

Log4j.Appender.socket.Layout = Org.apache.log4j.patternlayout

Log4j.Appender.socet.Layout.conversionPattern = [start]% D {date} [DATE]% N% p [priority]% N% x [NDC]% N% T [THREAD]% N% C [category]% N% M [Message]% N% N

################################

# Log Factor 5 appender

################################

Log4j.Appender.lf5_appender = org.apache.log4j.lf5.lf5appender

Log4j.Appender.lf5_appender.maxNumberofRecords = 2000

################################

# SMTP Appender

##############################

Log4j.appender.mail = org.apache.log4j.net.smtpappender

Log4j.Appender.mail.threshold = Fatal

Log4j.Appender.mail.buffersize = 10

Log4j.appender.mail.from=chenyl@hollycrm.com

Log4j.Appender.mail.smtphost = mail.hollycrm.com

Log4j.Appender.mail.subject = log4j message

Log4j.Appender.mail.to=chenyl@hollycrm.com

Log4j.Appender.mail.Layout = Org.apache.log4j.patternlayout

Log4j.Appender.mail.Layout.conversionPattern = [framework]% D-% C -% - 4R [% T]% -5p% C% X-% M% N

################################

# JDBC Appender

##############################

Log4j.Appender.database = org.apache.log4j.jdbc.jdbcappender

Log4j.Appender.Database.URL = JDBC: MySQL: // localhost: 3306 / test

Log4j.Appender.Database.driver = com.mysql.jdbc.driver

Log4j.Appender.Database.user = root

Log4j.Appender.Database.password =

Log4j.Appender.database.sql = INSERT INTO log4j (Message) VALUES ('[Framework]% D-% C -% - 4R [% T]% -5p% C% X -% M% N')

Log4j.Appender.Database.Layout = Org.apache.log4j.patternlayout

Log4j.Appender.database.Layout.conversionPattern = [framework]% D -% C -% - 4R [% T]% -5p% C% X-% M% NLog4j.Appender.a1 = org.apache.log4j.dailyrollingFileAppender

Log4j.Appender.a1.file = SampleMessages.log4j

Log4j.Appender.a1.datepattern = yyyymmdd-hh'.log4j '

Log4j.Appender.a1.Layout = org.apache.log4j.xml.xmlLayout

###################

# CustomAppender

###################

Log4j.Appender.im = net.cybercorlin.util.logger.Appender.Imappender

Log4j.Appender.im.host = mail.cybercorlin.net

Log4j.Appender.im.username = username

Log4j.Appender.im.password = password

Log4j.Appender.im.recipient = corlin@cybercorlin.net

Log4j.Appender.im.Layout = org.apache.log4j.patternlayout

Log4j.Appender.im.Layout.conversionPattern = [framework]% D-% C -% - 4R [% T]% -5p% C% X-% M% N

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

New Post(0)