You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by pradeep <pr...@jgsullivan.com> on 2001/08/17 15:54:32 UTC

How to log o/p to a specified file location

Hi Guys,
My problem is very simple.I need to direct my log file output to a location 
i specify.
This is what i use
My xml config file is as shown below:My java code as shown where strXmlFile 
is the file location of xml file
Im using the jbuilder environment to run .The output log is going to the 
working directory of jbuilder
Is there a way to change the o/p file location using log4j xml config file 
or api calls
ps let me know if any
thx
pradeep.

Java code
strXmlfile=ResourceManager.getResource(LOG_FILE_LOCATION, null);
log4j=Category.getInstance(OemsSystemLog.class.getName());
DOMConfigurator.configure(strXmlfile);

XMl file
<?xml version="1.0" encoding="UTF-8"?>
<!-- This file is the configuartion files for all logging activities -->
<!-- This file prints int a file called oemssys.log-->
<!-- To print the o/p to console comment the section 'FILE COMMENTS START 
HERE'
AND uncomment 'CONSOLE'.The default is file o/p.-->
<!-- SEARCH FOR 'DEBUG' and follow the instruction to disable log message-->
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<!--FILE COMMENTS START HERE-->
<appender name="systemlog" class="org.apache.log4j.FileAppender">
<param name="File" value="oemsys.log"/>-
<!--FILE END COMMENTS HERE-->
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{dd MMM yyyy HH:mm:ss} | %C{1} | 
%-5p | - %m\n"/>
</layout>
</appender>
<category name="com.oems.util.OemsSystemLog">
<!--DEBUG change the value to fatal if u need to disable log messages -->
<priority value="info"/>
</category>
<root>
<priority value="info"/>
<appender-ref ref="systemlog"/>
</root>
</log4j:configuration>
thx




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