ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » log4j

Post new topic  Reply to topic
 log4j « View previous topic :: View next topic » 
Author Message
newbieToMB
PostPosted: Fri Jul 14, 2006 6:34 am    Post subject: log4j Reply with quote

Newbie

Joined: 23 May 2006
Posts: 6

I am having problems getting log4j appenders initialized. I am doing this via a properties file. So all I code in my java compute node is the getLogger. I have the following properties file. Where does this have to be stored so the classloader can find it when running my message flow?

I get the standard warning about no Appenders.

I also tried using XML and deploying with my bar file. This did not work either. Of course I don't know if the XML log4j file is correctly coded.


log4j.properties
---------------------

# Set root logger level to DEBUG and its only appender to A1.
log4j.rootLogger=DEBUG,A1

# A1 set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender
# A1 is set to be a FileAppender.
#log4j.appender.A1=org.apache.log4j.FileAppender
#log4j.appender.A1=org.apache.log4j.RollingFileAppender


# A1 uses a file.
#log4j.appender.A1.file=C:\\mylog4jfile.log

# For RollingFileAppender, don't append, overwrite
#log4j.appender.A1.Append=false

# For RollingFileAppender, control the maximum log file size
#log4j.appender.A1.MaxFileSize=100MB

# For RollingFileAppender, keep backup files (backups will be name in filename.1, .2, etc)
#log4j.appender.A1.MaxBackupIndex=3

# A1 uses PatternLayout.
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n

log4j.xml
-------------

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

<!-- Log4J configuration file -->

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true">

<!-- Appenders -->

<appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="[%-5p][%-30.30c:%-3L] %m%n"/>
<!--param name="ConversionPattern"
value="%M[%-5p][%F:%L] %m%n"-->
</layout>
</appender>

<appender name="LOGFILE" class="org.apache.log4j.FileAppender">
<param name="File" value="c:/TEMP/mylog4jfile.log"/>
<param name="Append" value="false"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p - %m%n"/>
</layout>
</appender>

<!-- Categories -->

<category name="rootLogger">
<priority value="DEBUG"/>
</category>


<root>
<priority value="DEBUG" />
<appender-ref ref="LOGFILE" />
</root>
</log4j:configuration>
Back to top
View user's profile Send private message
jboller001
PostPosted: Fri Jul 14, 2006 7:11 am    Post subject: Reply with quote

Apprentice

Joined: 31 May 2006
Posts: 40

I add the properties file to the user.home directory and execute the following code:

private static final String LOG4J_PROPS = "log4j.properties";

String userHome = System.getProperty("user.home");
String separator = System.getProperty("file.separator");

PropertyConfigurator.configureAndWatch(userHome + separator
+ LOG4J_PROPS);
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » log4j
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.