0

I am using slf4j over java util logging. I am trying to place logging.properties file so that it will picked up by my webapp. The following is how my logging.properties file look like:

# Logging
handlers = java.util.logging.FileHandler, java.util.logging.ConsoleHandler
.level = ALL

# File Logging
java.util.logging.FileHandler.pattern = c:/logs/myApp.log
java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
java.util.logging.FileHandler.level = FINE

java.util.logging.ConsoleHandler.level = FINE
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter

com.foo.bar.level=ALL

I am NOT doing -Djava.util.logging.config.file="file_path/logging.properties. Instead I have put the logging.properties in my WEB-INF/classes and included this folder as a class folder in eclipse. I dont know if this is sufficient for things to work.

The log file myApp.log is not getting generated nor any logging happens in it. But anyways, the logging still occurs on the Eclipse console.

I suspect it is not taking this logging.properties file at all. But then I tried a suggestion from the posting - Java Logging - where is my log file? - I can see that it prints the file path with file name.

I will appreciate if some help can be provided in this regard.

NOTE: I am using slf4j over java util logging.

Community
  • 1
  • 1
Mahesh
  • 954
  • 8
  • 18
  • try `...pattern = c:\logs\myApp.log` – DwB Mar 12 '12 at 17:59
  • @DwB: My issue is not that java util logging is unable to find myApp.log. Rather it is unable to find logging.properties inside my WEB-INF/classes - sorry if I wasn't clear on this. – Mahesh Mar 13 '12 at 03:59

3 Answers3

1

Fixed the problem. Had to set -Djava.util.logging.config.file= "pathto\WEB-INF\classes\logging.properties in Arguments tab - Open Server->Open Launch Configuration in Eclipse

Mahesh
  • 954
  • 8
  • 18
0

JUL property file is never loaded from the classpath of the application classloader. The classes of the JUL are loaded in the context of the system classloader. The classpath of you application is unknown on this level. Therefore you need to specify the file location manually as:

-Djava.util.logging.config.file=<location>

The default location is lib/logging.properties inside the JRE directory.

Here is a useful link about classloader hierarchy of the WebLogic:

https://docs.oracle.com/en/middleware/fusion-middleware/weblogic-server/12.2.1.4/wlprg/classloading.html#GUID-7932D476-4282-462E-AF84-0EAD3CD97021

30thh
  • 10,861
  • 6
  • 32
  • 42
0

Don't use an absolute path for your log fine. Instead, just write :

# File Logging
java.util.logging.FileHandler.pattern = myApp.log

Then you can look for myApp.log with a file search tool, and use a relative path based on the default path you will find.

foch
  • 1,039
  • 10
  • 21
  • My issue is not that java util logging is unable to find myApp.log. Rather it is unable to find logging.properties inside my WEB-INF/classes - sorry if I wasn't clear on this. – Mahesh Mar 13 '12 at 03:58
  • Fixed the problem. Followed instructions in [link](http://stackoverflow.com/questions/2233053/where-can-i-view-tomcat-log-files-in-eclipse). Had to set -Djava.util.logging.config.file= "pathto\WEB-INF\classes\logging.properties in Arguments tab - Open Server->Open Launch Configuration in Eclipse – Mahesh Mar 14 '12 at 07:01