Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » Custom Logger(org.eclipse.scout.commons.logger.CustomLogManager not found.)
Custom Logger [message #1221752] Wed, 18 December 2013 06:08 Go to next message
Jeremie Bresson is currently offline Jeremie Bresson
Messages: 625
Registered: October 2011
Senior Member
Hi,

I try to get the ScoutLogger redirected to Slf4j.

I have seen the Logging wiki page. I think my solution could be to use a Custom Logger. Here is what I have done so far:
* I have commented the entries in my config ini, corresponding to the "Eclipse Log Framework" approach.
* I have added a new Class:
org.eclipse.scout.commons.logger.CustomLogManager located in <my app>.shared/src/org/eclipse/scout/commons/logger/CustomLogManager.java

package org.eclipse.scout.commons.logger;

//..

public class CustomLogManager implements IScoutLogManager {

    //..

    @Override
    public IScoutLogger getLogger(String name) {
        //here I want to return a LogWrapper extending AbstractScoutLogger and using SLF4j.
    }

    //..
}


The approach is similar to this how to: Create a CustomLogManager for log4j, but using SLF4j instead of Log4j.


The problem is that my CustomLogManager seems to be ignored. When I debug:
org.eclipse.scout.commons.logger.ScoutLogManager#createScoutLogManager()
    // no logging strategy set. Try to find class 'org.eclipse.scout.commons.logger.CustomLogManager' for custom logging
    if (Activator.getDefault() != null) {
      try {
        Class clazz = Activator.getDefault().getBundle().loadClass("org.eclipse.scout.commons.logger.CustomLogManager");
        if (clazz != null && IScoutLogManager.class.isAssignableFrom(clazz)) {
          return (IScoutLogManager) clazz.newInstance();
        }
      }
      catch (ClassNotFoundException e) {
        // nop (custom logger is not installed)
      }
      catch (Exception e) {
        // error cannot be logged by log manager as not installed yet
        e.printStackTrace();
      }
    }


When the class is loaded, it is not found. I go through the ClassNotFoundException catch block.

What do I need to do?

I have tried to add org.eclipse.scout.commons.logger in the Export-Package in
<my app>.shared/META-INF/MANIFEST.MF. No success so far.

Thanks in advance for your help.
Re: Custom Logger [message #1221756 is a reply to message #1221752] Wed, 18 December 2013 06:14 Go to previous messageGo to next message
Stephan Leicht Vogt is currently offline Stephan Leicht Vogt
Messages: 102
Registered: February 2010
Location: Baden Switzerland
Senior Member

Hi

Your CustomLogManager Class must be in a Fragment to org.eclipse.scout.commons.

See https://wiki.eclipse.org/Scout/HowTo/Create_a_CustomLogManager_for_log4j#Creating_the_new_fragment.

Greetings
Stephan
Re: Custom Logger [message #1221772 is a reply to message #1221756] Wed, 18 December 2013 06:58 Go to previous message
Jeremie Bresson is currently offline Jeremie Bresson
Messages: 625
Registered: October 2011
Senior Member
Sorry, I missed that part... It is written on both wiki pages.

Thank you.
Previous Topic:AbstractDoubleColumn: rounding decimal values
Next Topic:How to change theme on RAP client
Goto Forum:
  


Current Time: Wed Jul 23 18:28:10 EDT 2014

Powered by FUDForum. Page generated in 0.01559 seconds