• Post Reply Bookmark Topic Watch Topic
  • New Topic

Configuring Java Logging  RSS feed

 
Sverre Moe
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to configure the Java Logging API in my application and with no success.

I have created the file myLogging.properties in my application project and included the VM parameter -Djava.util.logging.config.file=myLogging.properties when I run my application. Where am I supposed to place this file. It is in the application jar file.

When using the above VM parameter no logging is either outputed to the screen nor saved in a log file.

Have the following configuration in myLogging.properties:



How can I change the date format. When using Java's default logging properties I get the date in the following format 01.sep.2008 16:10:41.
I want the date to be
DD.MM.YYYY HH.MM.SS.SSS

Also the logging message is split onto two lines. How can I get these to settle on the same line?

01.sep.2008 16:10:41 com.my.project.application myMethod
INFO: My Info Message


I wanted to use Java's own logging API instead of log4j, but so far its seems like more trouble to get the desired results.

I have tried searching the web, but could not find anything usefull for Java Logging API. Most of the configuration I have found deals with programatic configuration. And all sources are only telling to override the default configuration and use the extra VM parameter. Not much usefull information about advanced configuration.
[ September 01, 2008: Message edited by: Sverre Moe ]
 
Wesley Baker
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From my experience, the logging API is actually not that flexible, at least not in the areas you want to customize. My only suggestion would be to start researching overriding some of the logging classes to get your desired results.

Here are the steps my class goes through to create the file and write to it:

1: Create the file handler


2: Add the file handler to the logging object


3: Set your logging levels


4: Write to the file
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!