logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gunter Sammet" <Gun...@sammet.net>
Subject RE: Logging at Run Time
Date Tue, 11 Sep 2001 01:43:11 GMT
You have five priorities. Debug, info, warn, error and fatal. You can use
them e.g. cat.debug("This is a debug message"), cat. info("Just wanted to
let you know that it works"), cat.warn("Be careful, otherwise I might create
some problems"), etc..

I'm not sure if you want to change the configuration while the program is
running. Haven't done that and I'm not sure if it works. But you can
enable/disable through XML or properties file. I use XML, and that's one
sample how it could look like:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration debug="false">

        <appender name="A1" class="org.apache.log4j.DatedFileAppender">
		<param name="File" value="C:/occ/logs/occ.log"/>
                <param name="Append" value="true" />
		<layout class="org.apache.log4j.PatternLayout">
  		     <param name="ConversionPattern"
                            value="%d %-5p [%t] %C{2} (%F:%L) - %m%n"/>
		</layout>
	</appender>

        <appender name="A2" class="org.apache.log4j.ConsoleAppender">
		<layout class="org.apache.log4j.PatternLayout">
  		     <param name="ConversionPattern"
                            value="%d %-5p [%t] %C{2} (%F:%L) - %m%n"/>
		</layout>
	</appender>

	<appender name="LF5Appender" class="com.servidium.lf5.LF5Appender">
		<param name="MaxNumberOfRecords" value="1000" />

	</appender>

	<!--This is a package-->
	<category name="org.apache.log4j.xml">
	  <priority value="info" />
  	   <appender-ref ref="A1" />
   	   <appender-ref ref="A2" />
	</category>

	<!--This is a package-->
	<category name="occproject">
	  <priority value="debug" />
  	   <appender-ref ref="A1" />
   	   <appender-ref ref="A2" />
	</category>

	<root>
	   <priority value ="info" />
   	   <appender-ref ref="A1" />
   	   <appender-ref ref="A2" />
           <appender-ref ref="LF5Appender" />
	</root>

</log4j:configuration>

Hope this helps!

Gunter

PS: DatedFileAppender is an addition and I'm not sure if it is already in
your package. LF5Appender is a class from a graphical tool.

-----Original Message-----
From: log4j-user-return-2974-Gunter=sammet.net@jakarta.apache.org
[mailto:log4j-user-return-2974-Gunter=sammet.net@jakarta.apache.org]On
Behalf Of Abhijat Thakur
Sent: Monday, September 10, 2001 7:15 PM
To: log4j-user@jakarta.apache.org
Subject: Logging at Run Time


Hi,

I had a few doubts

*Can a Category have more than one Priority.
*If a priority for a category is enabled how can it be disabled at run time.

Thanks a lot

Abhijat Thakur

bDNA Corporation


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org


Mime
View raw message