Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Other Open Source Projects and the fly likes Log4j in Eclipse Vs Log4j Outside Eclipse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Log4j in Eclipse Vs Log4j Outside Eclipse" Watch "Log4j in Eclipse Vs Log4j Outside Eclipse" New topic
Author

Log4j in Eclipse Vs Log4j Outside Eclipse

Tauri Valor
Ranch Hand

Joined: Aug 03, 2005
Posts: 166
Hi

I am succesfully creating the log in different files including eclipse console when Im running my application from Eclipse using Tomcat4.1

I placed my log4j.properties in WEB-INF/classes.

But when I run the same application outside the eclipse using my Batch file, I could see the log in the console, but I couldnt see the logs in my log files..

Can anyone please tell me the probable reason for this behaviour ?

Thanks,
Sudheer


A Moment's insight is sometimes worth a Life's experience.
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
Since you haven't included details about how you've configured log4j, I can only gues that you've specified a relative path for the file that log4j is to use and you may not be able to find where it is putting it when running outside of eclipse.

Are you running with log4j.debug=true to see any debug output it might be giving you?
Tauri Valor
Ranch Hand

Joined: Aug 03, 2005
Posts: 166
This is my log4j.properties placed in WEB-INF/Classes.

# Create two appenders, one called stdout and the other called rolling
log4j.rootLogger=DEBUG, VDSConsole, VDSDebug, VDSInfo, VDSError, VDSWarn

# Configure the VDSConsole appender
log4j.appender.VDSConsole=org.apache.log4j.ConsoleAppender
log4j.appender.VDSConsole.layout=org.apache.log4j.PatternLayout
log4j.appender.VDSConsole.layout.ConversionPattern=%d{yyyy-MMM-dd HH:mm:ss,SSS} - %p %c - %m%n

# Configure the VDSDebug appender
log4j.appender.VDSDebug=org.apache.log4j.RollingFileAppender
log4j.appender.VDSDebug.File=/logs/VDS_DEBUG.log
log4j.appender.VDSDebug.MaxFileSize=50000KB
log4j.appender.VDSDebug.MaxBackupIndex=1
log4j.appender.VDSDebug.Threshold=DEBUG
log4j.appender.VDSDebug.layout=org.apache.log4j.PatternLayout
log4j.appender.VDSDebug.layout.ConversionPattern=%d{yyyy-MMM-dd HH:mm:ss,SSS} - %p %c - %m%n

# Configure the VDSInfo appender
log4j.appender.VDSInfo=org.apache.log4j.RollingFileAppender
log4j.appender.VDSInfo.File=/logs/VDS_INFO.log
log4j.appender.VDSInfo.MaxFileSize=5000KB
log4j.appender.VDSInfo.MaxBackupIndex=1
log4j.appender.VDSInfo.Threshold=INFO
log4j.appender.VDSInfo.layout=org.apache.log4j.PatternLayout
log4j.appender.VDSInfo.layout.ConversionPattern=%d{yyyy-MMM-dd HH:mm:ss,SSS} - %p %c - %m%n

# Configure the VDSError appender
log4j.appender.VDSError=org.apache.log4j.RollingFileAppender
log4j.appender.VDSError.File=/logs/VDS_ERROR.log
log4j.appender.VDSError.MaxFileSize=5000KB
log4j.appender.VDSError.MaxBackupIndex=1
log4j.appender.VDSError.Threshold=ERROR
log4j.appender.VDSError.layout=org.apache.log4j.PatternLayout
log4j.appender.VDSError.layout.ConversionPattern=%d{yyyy-MMM-dd HH:mm:ss,SSS} - %p %c - %m%n

# Configure the VDSWarn appender
log4j.appender.VDSWarn=org.apache.log4j.RollingFileAppender
log4j.appender.VDSWarn.File=/logs/VDS_WARN.log
log4j.appender.VDSWarn.MaxFileSize=5000KB
log4j.appender.VDSWarn.MaxBackupIndex=1
log4j.appender.VDSWarn.Threshold=WARN
log4j.appender.VDSWarn.layout=org.apache.log4j.PatternLayout
log4j.appender.VDSWarn.layout.ConversionPattern=%d{yyyy-MMM-dd HH:mm:ss,SSS} - %p %c - %m%n

# Configure the VDSFatal appender
log4j.appender.VDSFatal=org.apache.log4j.RollingFileAppender
log4j.appender.VDSFatal.File=/logs/VDS_FATAL.log
log4j.appender.VDSFatal.MaxFileSize=5000KB
log4j.appender.VDSFatal.MaxBackupIndex=1
log4j.appender.VDSFatal.Threshold=FATAL
log4j.appender.VDSFatal.layout=org.apache.log4j.PatternLayout
log4j.appender.VDSFatal.layout.ConversionPattern=%d{yyyy-MMM-dd HH:mm:ss,SSS} - %p %c - %m%n[/CODE]


I wrote a Wrapper for Logger class which wraps logger.info,logger.debug...

This wrappers works fine when I run the application in eclipse.

But when Im running the tomcat externally, I couldnt find the log in my log files..but I can see the some log in console...

Please let me know if you need more explanation of my problem..
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
Does the /logs directory exist?

What kind of debug output did you get from using log4j.debug=true?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Log4j in Eclipse Vs Log4j Outside Eclipse
 
Similar Threads
logs problem in websphere application server
logging in websphere
Create user wise Log file.
log files
remove log4j appender from an API