logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sriram Venkatasubramanian" <Sriram.Venkatasubraman...@adeasolutions.com>
Subject RE: Clarification & More help required
Date Thu, 07 Jul 2005 05:49:58 GMT
Hi All, 
I am also facing similar problem ! Log4j is unable read the env
variables. My problem is I cant hard code the path of the log file as
C:\XXX\xxLog.log. I have to read the relative path for this purpose .
Any idea ?

I am using OC4J & log4J 1.2.11  & My log4j.xml is as below. 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
debug="false">
	<appender name="DAO_FRAMEWORK"
class="org.apache.log4j.DailyRollingFileAppender">
		<param name="File"
value="$(JAVA_HOME)/DAOFramework.log"/>
		<param name="Append" value="true"/>
		<layout class="org.apache.log4j.PatternLayout">
			<param name="ConversionPattern" value="%d %-5p
[%c{1}] %m%n"/>
		</layout>
	</appender>
	<appender name="CONSOLE"
class="org.apache.log4j.ConsoleAppender">
		<param name="Threshold" value="INFO"/>
		<param name="Target" value="System.out"/>
		<layout class="org.apache.log4j.PatternLayout">
			<!-- The default pattern: Date Priority
[Category] Message\n -->
			<param name="ConversionPattern"
value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
		</layout>
	</appender>
		
	<!-- DAO Framework -->
	<logger name="DAO" additivity="false">
		<level value="INFO"/>
		<appender-ref ref="CONSOLE"/>
		<appender-ref ref="DAO_FRAMEWORK"/>
	</logger>	
	
	<!-- Root Logger -->
	<root>
	    <level value="DEBUG"/>
		<appender-ref ref="CONSOLE"/>
		<appender-ref ref="DAO_FRAMEWORK"/>
	</root>

</log4j:configuration>

 And I am getting  errors like :

Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)
initialized
log4j:ERROR setFile(null,true) call failed.
java.io.FileNotFoundException: $(JAVA_HOME)/DAOFramework.log (The system
cannot find the path specified)
      at java.io.FileOutputStream.openAppend(Native Method)
      at java.io.FileOutputStream.<init>(Unknown Source)
      at org.apache.log4j.FileAppender.setFile(FileAppender.java:282)
      at
org.apache.log4j.FileAppender.activateOptions(FileAppender.java:161)
      at
org.apache.log4j.DailyRollingFileAppender.activateOptions(DailyRollingFi
leAppender.java:215)
      at
org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:256)
      at
org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:
219)
      at
org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.
java:149)



I am calling Logger like this in Java Code :
		Logger logger =Logger.getLogger("DAO");
		logger.info("I am inside logger"+this);

Regards,
Sriram V


-----Original Message-----
From: Vinodh Srinivasasainagendra [mailto:vinodh@uab.edu] 
Sent: Wednesday, July 06, 2005 9:59 PM
To: 'Log4J Users List'
Subject: RE: Clarification

Did u try ${some_property_key} (for example, java.home or user.home
system
properties) to specify the path in front of the File.

Ex:

log4j.appender.dest2.File=${java.home}/log4j.log

~vinodh

-----Original Message-----
From: Balaji Saranathan [mailto:balaji.saranathan@wipro.com] 
Sent: Wednesday, July 06, 2005 11:06 AM
To: 'Log4J Users List'
Subject: RE: Clarification


But isnt this configuring through the code? I want to configure the
FileAppender from the log4j.properties file. 


-----Original Message-----
From: Vinodh Srinivasasainagendra [mailto:vinodh@uab.edu] 
Sent: Wednesday, July 06, 2005 12:01 PM
To: 'Log4J Users List'
Subject: RE: Clarification


See the attached code,

 

// Set FileAppender

            SimpleLayout layout = new SimpleLayout();

            String fileName = new
File(backupDir.getParent(),"error.log").getAbsolutePath();

            FileAppender appender = new FileAppender(layout,
fileName,true);

            

logger.addAppender(appender);

            logger.setLevel((Level) Level.FATAL);

            Date date = new Date(System.currentTimeMillis());

           

            logger.fatal(date.toString());

            logger.fatal(message);

 
logger.fatal("***************************************************");

 

Note:

Make sure you give the parent dir to the log file properly.

 

~vinodh 

-----Original Message-----
From: Balaji Saranathan [mailto:balaji.saranathan@wipro.com] 
Sent: Wednesday, July 06, 2005 10:47 AM
To: 'Log4J Users List'
Subject: RE: Clarification

 

 

Tx. I tried it. It doesn't work I still get the same error. In the error

below, there is a call to setFile with "null" filename. Shdnt it be

called with the filename mentioned in the properties file?

 

 

 

-----Original Message-----

From: Schuweiler, Joel J. [mailto:Schuweiler.Joel@mayo.edu] 

Sent: Wednesday, July 06, 2005 11:38 AM

To: 'Log4J Users List'

Subject: RE: Clarification

 

 

If can't find the path, have you tried removed the leading ./?

 

For a path I would do

 

logs/framework.log assuming that it is contained in the same directory

that your class is running from.

 

-----Original Message-----

From: Balaji Saranathan [mailto:balaji.saranathan@wipro.com] 

Sent: Wednesday, July 06, 2005 10:33 AM

To: 'Log4J Users List'

Subject: Clarification

 

 

 

Hi,

 

Can you tell me if log4j creates the log file (if they are not present)

when using the FileAppenders or is it the responsibility of the

developers to create the log files? I have a FileAppender configured and

when I configure the

log4j.appender.framework.File=framework.log=./logs/framework.log

I get a the following error on stdout.log

 

log4j:ERROR setFile(null,true) call failed.

java.io.FileNotFoundException: .\logs\framework.log (The system cannot

find the path specified)

      at java.io.FileOutputStream.openAppend(Native Method)

      at java.io.FileOutputStream.<init>(FileOutputStream.java:177)

      at java.io.FileOutputStream.<init>(FileOutputStream.java:102)

      at org.apache.log4j.FileAppender.setFile(FileAppender.java:282)

      at

org.apache.log4j.RollingFileAppender.setFile(RollingFileAppender.java:16

5)

      at

org.apache.log4j.FileAppender.activateOptions(FileAppender.java:161)

      at

org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:256)

      at

org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java

:132)

      at

org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java

:96)

      at

org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator

.java:654)

      at

org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator

.java:612)

      at

org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConf

igurator.java:509)

      at

org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.j

ava:415)

      at

org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.j

ava:441)

      at

org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConver

ter.java:468)

 

 

 

 

 

 

 

Confidentiality Notice 

 

The information contained in this electronic message and any attachments

to this message are intended for the exclusive use of the addressee(s)

and may contain confidential or privileged information. If you are not

the intended recipient, please notify the sender at Wipro or

Mailadmin@wipro.com immediately and destroy all copies of this message

and any attachments.

 

---------------------------------------------------------------------

To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org

For additional commands, e-mail: log4j-user-help@logging.apache.org

 

 

 

 

Confidentiality Notice 

 

The information contained in this electronic message and any attachments
to this message are intended

for the exclusive use of the addressee(s) and may contain confidential
or privileged information. If

you are not the intended recipient, please notify the sender at Wipro or
Mailadmin@wipro.com immediately

and destroy all copies of this message and any attachments.

 

---------------------------------------------------------------------

To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org

For additional commands, e-mail: log4j-user-help@logging.apache.org





Confidentiality Notice 

The information contained in this electronic message and any attachments
to
this message are intended
for the exclusive use of the addressee(s) and may contain confidential
or
privileged information. If
you are not the intended recipient, please notify the sender at Wipro or
Mailadmin@wipro.com immediately
and destroy all copies of this message and any attachments.

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

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


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


Mime
View raw message