MannikJ
MannikJ

Reputation: 311

How to set different log levels in Eclipse Scout framework?

I'm having some trouble configuring proper logging in Eclipse Scout framework. My claims aren't that high as I only want to be able to set different log levels for different parts of my program in a configuration/properties/XML file. The logging configuration in the config.ini of my Scout server plugin currently looks like this:

eclipse.consoleLog=true
org.eclipse.scout.log=eclipse
org.eclipse.scout.log.level=INFO

So as you can see this is the default logging configuration using Eclipse logging. It works fine for logging at a global level. The only thing I would like to do is to write something like this to set the different log levels:

packagename.ClassName=LOGLEVEL

As this is a very basic logging use case I think there must be some easy way to do this in Scout. Otherwise I would appreciate some help how to configure log4j, JUL or others for the use with Scout. The Eclipse Scout Wiki hasn't helped me so far. I created the example logger fragment to the host plugin 'org.eclipse.scout.commons' and removed the logging configuration lines from my config.ini but nothing happens. I'm also not sure where to put the log4j.poperties or how this is done otherwise.

I'm a bit ashamed for being unable to figure out such a basic problem, but would be very happy about some quick help.

Upvotes: 2

Views: 1003

Answers (1)

Patrick
Patrick

Reputation: 4860

I can tell you how to configure the logging if you choose the java logger (config.ini: org.eclipse.scout.log=java). For the eclipse logger, I barely found any information at all.

Now, to configure the java (JUL) logging: You can do this in a file called logging.properties.

You can configure the logging by specifying the configuration file in your product:

  1. Create your configuration file - say logging.properties inside the folder where your product file (for server or client respectively) is located. Typically this is in a folder named 'products'.
  2. Open your product file and go to the "Launching" tab and specify your logging configuration file in the "VM Arguments" tab. Use the "java.util.logging.config.file" system property to do so:

-Djava.util.logging.config.file="${resource_loc:/com.yourapp.server/products/logging.properties}"

Now, you should be able to specify the log levels in your new logging.properties file:

### Root level of your application, all below are ignored
.level=INFO
### Handlers
handlers=java.util.logging.ConsoleHandler
### Handler properties
java.util.logging.ConsoleHandler.level=FINEST
### Override the logging level for certain classes
com.yourapp.server.SomeService.level=FINE

Alternatively, you can also use a class to initialize the logging with the java.util.logging.config.class option. See this wiki page for a detailed example.

Also, when building a WAR file, you might be interested in this answer.

Upvotes: 2

Related Questions