This week's book giveaway is in the General Computing forum.
We're giving away four copies of Emmy in the Key of Code and have Aimee Lucido on-line!
See this thread for details.
Win a copy of Emmy in the Key of Code this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

log4j - creating my own file

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm trying to create a log4j log file with only output from the RallyLog class ( within the com.zzz.pr.components see below) and keep all the other portal logging the same.
Below is the only config that even works but turns off console debug level logging & I remember exceptions on the console (not good !) Any suggestions would be appreciated I have unsuccessfully tried a number of configurations including using filtering & a logger.
thanks

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

<appender name="PERF_LOG" class="org.apache.log4j.FileAppender">
<param name="File" value="c:/my_unique/providers/logs/perf.log" />
<param name="Threshold" value="info"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p %c{2} - %m\n"/>
</layout>
</appender>

<logger name="com.zzz.pr.components">
<level value="INFO"/>
</logger>

<root>
<level value ="OFF"/>
<appender-ref ref="PERF_LOG" />
</root>
</log4j:configuration>
 
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You want to keep the other logging the same as what?

Basically it looks like you need another appender and use one appender for the com.zz.pr.components logger and the other for the root logger.

Add an appender-ref to your com.zz.pr.components logger :
<appender-ref ref="OTHER_LOG" />

Doesn't help? Post the new xml.
[ March 31, 2005: Message edited by: Carol Enderlin ]
 
Chris Tobin
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you so much ! you were right !

this xml config creates a log file for info level messages generated from classes in the com.zz.pr.components package and also logs them to the console. All other logging messages are left in tact as before.

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="USER_LOG" class="org.apache.log4j.ConsoleAppender">
<param name="Threshold" value="debug"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p %c{2} - %m\n"/>
</layout>
</appender>
<appender name="MEM_LOG" class="com.zz.eas.framework.services.logging.MemoryAppender">
<param name="Threshold" value="error"/>
<param name="Size" value="1000"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p %c{2} - %m\n"/>
</layout>
</appender>
<appender name="PERF_LOG" class="org.apache.log4j.FileAppender">
<param name="File" value="c:/zz_unique/pr/logs/perf.log" />
<param name="Threshold" value="info"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p %c{2} - %m\n"/>
</layout>
</appender>

<logger name="com.zz.pr.components">
<level value="INFO"/>
<appender-ref ref="PERF_LOG" />
<appender-ref ref="USER_LOG" />
</logger>

<root>
<priority value ="debug" />
<appender-ref ref="USER_LOG" />
<appender-ref ref="MEM_LOG" />
</root>
</log4j:configuration>
--------------------

thanks in advance
 
I'm still in control here. LOOK at this tiny ad!
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!