Mailing List
Home
Forum Home
Maven - Project building tool
Axis - Java SOAP implementation
Cocoon - MVC web framework based on XML/XSL
Lucene - Full-featured text search engine APIs
Log4J - A log library
Fop - Create PDF, PCL, PS, SVG, XML driven by XSL formatting objects.
POI - Java Excel, Word and other Microsoft Office files manipulating library
Oracle database error code ...
Subjects
log4j warning: No appenders could be found
java security AccessControlException: access denied (java io FilePermission clie
java lang InstantiationException: org apache tools ant Main
Apache Axis Tutorial
Struts <logic iterate >
log4j properties How to parse outpu to multiple files
configuring log4j with BEA Weblogic 8 1
How to use XSL FOP Java together
JSP precompile
Servlet File Download dialog problem (IE6,Adobe 6 0)
Proposal: Adding jar manifest classpath in jar and war plugins
Unsupported major minor version 48 0 problem while running the an
   telope task
java security AccessControlException: access denied (java io FilePermission
axis wsdl2java Ant Task usage
net sf hibernate MappingException: Error reading resource: test/User hbm xml
Building EAR ANT Script for websphere 5 0
CREATING WAR Files
jsp data into Excel
Classpath problem
Jboss 3 2 3+ vs Tomcat Axis Question
RE: How to include jars and add them into the MANIFEST MF/Class Path
attribute
Printing problem
InstantiationException
Couldn 't find trusted certificate
Please : How can one install ant 1 6 0 under Eclipse 2 1 ?
Excel: Too many different cell formats
Running junit tests fails
XDoclet, Struts and Maven: Where to start? SOLUTION
1 3 final: now giving me java io FileNotFoundException (Too many
open files)
AXIS: tomcat timeout ?
 
Search:  
Power your search with and, or, +, -, or "some phrase" operators.
log4j.properties - How to parse outpu to multiple files

log4j.properties - How to parse outpu to multiple files

2003-10-09       - By Kevin Dougan

 Back
Reply:     1     2     3     4     5     6     7  

FYI: I've also created a log4j.properties files that does the same thing as the
log4j.xml file listed in the attached email:

log4j.threshold=ALL
log4j.rootLogger=ALL, stdout, DebugAppender, InfoAppender, WarnAppender,
ErrorAppender

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%c %d{ISO8601} -- %p -- %m%n

log4j.appender.DebugAppender=org.apache.log4j.RollingFileAppender
log4j.appender.DebugAppender.File=C:\\logs\\app-debug.log
log4j.appender.DebugAppender.MaxFileSizeP0KB
log4j.appender.DebugAppender.MaxBackupIndex
log4j.appender.DebugAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.DebugAppender.layout.ConversionPattern=%c %d{ISO8601} -- %p --
%m%n
log4j.appender.DebugAppender.Threshold?BUG

log4j.appender.InfoAppender=org.apache.log4j.RollingFileAppender
log4j.appender.InfoAppender.File=C:\\logs\\app-info.log
log4j.appender.InfoAppender.MaxFileSizeP0KB
log4j.appender.InfoAppender.MaxBackupIndex
log4j.appender.InfoAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.InfoAppender.layout.ConversionPattern=%c %d{ISO8601} -- %p -- %m
%n
log4j.appender.InfoAppender.Threshold=INFO

log4j.appender.WarnAppender=org.apache.log4j.RollingFileAppender
log4j.appender.WarnAppender.File=C:\\logs\\app-warn.log
log4j.appender.WarnAppender.MaxFileSizeP0KB
log4j.appender.WarnAppender.MaxBackupIndex
log4j.appender.WarnAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.WarnAppender.layout.ConversionPattern=%c %d{ISO8601} -- %p -- %m
%n
log4j.appender.WarnAppender.Threshold=WARN

log4j.appender.ErrorAppender=org.apache.log4j.RollingFileAppender
log4j.appender.ErrorAppender.File=C:\\logs\\app-error.log
log4j.appender.ErrorAppender.MaxFileSizeP0KB
log4j.appender.ErrorAppender.MaxBackupIndex
log4j.appender.ErrorAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.ErrorAppender.layout.ConversionPattern=%c %d{ISO8601} -- %p --
%m%n
log4j.appender.ErrorAppender.Threshold=ERROR

-- --Original Message-- --
From: Kevin Dougan
Sent: October 9, 2003 12:16 AM
To: Log4J Users List
Subject: RE: log4j.properties - How to parse outpu to multiple files


Eureka! I have a solution! I now have my logging messages split out into the 4
types that I support: DEBUG, INFO, WARN & ERROR. My app-debug.log file contains
everything, down to my app-error.log file which only contains errors!

Why is it that these moments tend to occur after midnight...   :-)

Note: I switched from log4j.properties to log4j.xml in order to take advantage
of filters, which aren't supported in the properties file.

Here's my log4j.xml file, enjoy:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>

  <appender name="STDOUT" class="org.apache.log4j.ConsoleAppender Source code of org.apache.log4j.ConsoleAppender">
    <layout class="org.apache.log4j.PatternLayout Source code of org.apache.log4j.PatternLayout">
          <param name="ConversionPattern" value="%c %d{ISO8601} -- %p -- %m%n"/>
    </layout>
  </appender>

  <appender name="DEBUG" class="org.apache.log4j.RollingFileAppender Source code of org.apache.log4j.RollingFileAppender">
     <param name="File" value="C:\\logs\\app-debug.log"/>
     <param name="Append" value="true"/>
     <param name="MaxFileSize" value="500KB"/>
     <param name="MaxBackupIndex" value="2"/>
    <layout class="org.apache.log4j.PatternLayout Source code of org.apache.log4j.PatternLayout">
          <param name="ConversionPattern" value="%c %d{ISO8601} -- %p -- %m%n"/>
    </layout>
  </appender>

  <appender name="INFO" class="org.apache.log4j.RollingFileAppender Source code of org.apache.log4j.RollingFileAppender">
     <param name="File" value="C:\\logs\\app-info.log"/>
     <param name="Append" value="true"/>
     <param name="MaxFileSize" value="500KB"/>
     <param name="MaxBackupIndex" value="2"/>
    <layout class="org.apache.log4j.PatternLayout Source code of org.apache.log4j.PatternLayout">
          <param name="ConversionPattern" value="%c %d{ISO8601} -- %p -- %m%n"/>
    </layout>
    <filter class="org.apache.log4j.varia.LevelRangeFilter Source code of org.apache.log4j.varia.LevelRangeFilter">
      <param name="LevelMin" value="INFO" />
    </filter>
  </appender>

  <appender name="WARN" class="org.apache.log4j.RollingFileAppender Source code of org.apache.log4j.RollingFileAppender">
     <param name="File" value="C:\\logs\\app-warn.log"/>
     <param name="Append" value="true"/>
     <param name="MaxFileSize" value="500KB"/>
     <param name="MaxBackupIndex" value="2"/>
    <layout class="org.apache.log4j.PatternLayout Source code of org.apache.log4j.PatternLayout">
          <param name="ConversionPattern" value="%c %d{ISO8601} -- %p -- %m%n"/>
    </layout>
    <filter class="org.apache.log4j.varia.LevelRangeFilter Source code of org.apache.log4j.varia.LevelRangeFilter">
      <param name="LevelMin" value="WARN" />
    </filter>
  </appender>

  <appender name="ERROR" class="org.apache.log4j.RollingFileAppender Source code of org.apache.log4j.RollingFileAppender">
     <param name="File" value="C:\\logs\\app-error.log"/>
     <param name="Append" value="true"/>
     <param name="MaxFileSize" value="500KB"/>
     <param name="MaxBackupIndex" value="2"/>
    <layout class="org.apache.log4j.PatternLayout Source code of org.apache.log4j.PatternLayout">
          <param name="ConversionPattern" value="%c %d{ISO8601} -- %p -- %m%n"/>
    </layout>
    <filter class="org.apache.log4j.varia.LevelRangeFilter Source code of org.apache.log4j.varia.LevelRangeFilter">
      <param name="LevelMin" value="ERROR" />
    </filter>
  </appender>

  <root>
    <priority value="debug"/>
    <appender-ref ref="STDOUT"/>
      <appender-ref ref="DEBUG"/>
    <appender-ref ref="INFO"/>
    <appender-ref ref="WARN"/>
    <appender-ref ref="ERROR"/>
  </root>

</log4j:configuration>

-- --Original Message-- --
From: Kevin Dougan
Sent: October 8, 2003 3:09 PM
To: log4j-user@(protected)
Subject: log4j.properties - How to parse outpu to multiple files


Greetings log4j list!

I'd like my logging output to be sent to multiple files at once. However, I
only want ERRORs in the app-error.log file, DEBUG in the app-debug.log file,
etc. As a potential compromise, I would be OK if I was able to at least reduce
the types of log messages as the severity increased.

Can anyone assist with my log4.properties file? I've included a copy below, but
note that this config sends all the logging output to all files.

In addition, is there a way to avoid all the duplication in this config file,
so I just have to change the name of the output file in each case, and inherit
all the RollingFileAppender settings as I define each file?

Thanks!

log4j.threshold=ALL
log4j.rootLogger=ALL, stdout, DebugAppender, InfoAppender, WarnAppender,
ErrorAppender

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%c %d{ISO8601} -- %p -- %m%n

log4j.logger.DebugAppender.access?BUG
log4j.appender.DebugAppender=org.apache.log4j.RollingFileAppender
log4j.appender.DebugAppender.File=C:\\logs\\app-debug.log
log4j.appender.DebugAppender.MaxFileSizeP0KB
log4j.appender.DebugAppender.MaxBackupIndex
log4j.appender.DebugAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.DebugAppender.layout.ConversionPattern=%c %d{ISO8601} -- %p --
%m%n

log4j.logger.InfoAppender.access=INFO
log4j.appender.InfoAppender=org.apache.log4j.RollingFileAppender
log4j.appender.InfoAppender.File=C:\\logs\\app-info.log
log4j.appender.InfoAppender.MaxFileSizeP0KB
log4j.appender.InfoAppender.MaxBackupIndex
log4j.appender.InfoAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.InfoAppender.layout.ConversionPattern=%c %d{ISO8601} -- %p -- %m
%n

log4j.logger.WarnAppender.access=WARN
log4j.appender.WarnAppender=org.apache.log4j.RollingFileAppender
log4j.appender.WarnAppender.File=C:\\logs\\app-warn.log
log4j.appender.WarnAppender.MaxFileSizeP0KB
log4j.appender.WarnAppender.MaxBackupIndex
log4j.appender.WarnAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.WarnAppender.layout.ConversionPattern=%c %d{ISO8601} -- %p -- %m
%n

log4j.logger.ErrorAppender.access=ERROR
log4j.appender.ErrorAppender=org.apache.log4j.RollingFileAppender
log4j.appender.ErrorAppender.File=C:\\logs\\app-error.log
log4j.appender.ErrorAppender.MaxFileSizeP0KB
log4j.appender.ErrorAppender.MaxBackupIndex
log4j.appender.ErrorAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.ErrorAppender.layout.ConversionPattern=%c %d{ISO8601} -- %p --
%m%n

Kevin Dougan - kdougan@(protected)
Systems Architect
IT - Business Systems
Research In Motion - www.rim.com
BlackBerry Cell: 519-572-9417
Desk Phone: 519-888-7465  ext. 2451

This transmission may contain confidential or privileged material. Any use of
this information by anyone other than the intended recipient is prohibited. If
you have received this transmission in error, please immediately reply to the
sender and delete this information from your system. Use, dissemination,
distribution, or reproduction of this transmission by unintended recipients is
not authorized and may be unlawful.



-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
To unsubscribe, e-mail: log4j-user-unsubscribe@(protected)
For additional commands, e-mail: log4j-user-help@(protected)


-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
To unsubscribe, e-mail: log4j-user-unsubscribe@(protected)
For additional commands, e-mail: log4j-user-help@(protected)


-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
To unsubscribe, e-mail: log4j-user-unsubscribe@(protected)
For additional commands, e-mail: log4j-user-help@(protected)



Earn $52 per hosting referral at Lunarpages.