Log4j configuration full set of functions

xiaoxiao2021-03-06  96

Log4j's configuration is simple to make it more and more applications:

The log4j configuration file implements the output to the console, file, rollback file, send log mail, output to database log table, custom label, etc. Choose its one or two uses enough,

log4j.rootLogger = DEBUG, CONSOLE, A1, imlog4j.addivity.org.apache = true # to Console log4j.appender.CONSOLE = org.apache.log4j.ConsoleAppenderlog4j.appender.Threshold = DEBUGlog4j.appender.CONSOLE.Target = System.Outlog4j.Appender.console.Layout = org.apache.log4j.patternlayoutlog4j.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 # is applied to files

log4j.appender.FILE = org.apache.log4j.FileAppenderlog4j.appender.FILE.File = file.loglog4j.appender.FILE.Append = falselog4j.appender.FILE.layout = org.apache.log4j.PatternLayoutlog4j.appender.FILE. Layout.conversionPattern = [framework]% D -% C -% - 4R [% T]% -5p% C% X -% M% N # Use this layout for logfactor 5 Analysis # is applied to file rollback log4j.Appender. ROLLING_FILE = org.apache.log4j.RollingFileAppenderlog4j.appender.ROLLING_FILE.Threshold = ERRORlog4j.appender.ROLLING_FILE.File = rolling.loglog4j.appender.ROLLING_FILE.Append = truelog4j.appender.ROLLING_FILE.MaxFileSize = 10KBlog4j.appender.ROLLING_FILE.MaxBackupIndex = 1 Log4j.Appender.Rolling_File.Layout = org.apache.log4j.patternlayoutLog4j.Appender.rolling_file.Layout.conversionPattern = [framework]% D -% C -% - 4R [% T]% -5p% C% X -% M % n # applied socketlog4j.appender.SOCKET = org.apache.log4j.RollingFileAppenderlog4j.appender.SOCKET.RemoteHost = localhostlog4j.appender.SOCKET.Port = 5001log4j.appender.SOCKET.LocationInfo = true # Set up for Log facter 5log4j. appender.socket.layout = org.apa Che.log4j.patternlayoutlog4j.ppender.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 Appenderlog4j.appender.LF5_APPENDER = org.apache.log4j.lf5.LF5Appenderlog4j.appender.LF5_APPENDER.MaxNumberOfRecords = 2000 # to send log messages log4j.appender. MAIL=org.apache.log4j.net.SMTPAppenderlog4j.appender.MAIL.Threshold=FATALlog4j.appender.MAIL.BufferSize=10log4j.appender.MAIL.From=web@www.wuset.comlog4j.appender.MAIL.SMTPHost=www. WuseU.comlog4j.Appender.mail.subject = log4j messageelog4j.Appender.mail.to=web@www.wusetu.comlog4j.Appender.mail.Layout=

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

New Post(0)