Opened 13 years ago

Closed 13 years ago

#10 closed task (worksforme)

Study slf4j

Reported by: smoser Owned by: dgermann
Priority: major Milestone:
Component: Architecture Version:
Keywords: Cc:

Description


Change History (7)

comment:1 Changed 13 years ago by dgermann

  • first implementation of FlarmLoggerFactory?, tested with FlarmLoggerFactoryTest? (JUnit)
  • configuration file (lib.log.resource/META-INF/log4j.xml) just with default values
  • added new maven dependency (slf4j-simple-1-6-6.jar)

comment:2 Changed 13 years ago by smoser

15:11:32,309 ERROR [stderr] (MSC service thread 1-1) log4j:ERROR Could not parse file content/ch.netzschmiede.flarmradar-0.0.1-SNAPSHOT.ear/lib/ch.netzschmiede.flarmradar.lib.log-0.0.1-SNAPSHOT.jar/META-INF/log4j.xml.
15:11:32,312 ERROR [stderr] (MSC service thread 1-1) java.io.FileNotFoundException?: /content/ch.netzschmiede.flarmradar-0.0.1-SNAPSHOT.ear/lib/ch.netzschmiede.flarmradar.lib.log-0.0.1-SNAPSHOT.jar/META-INF/log4j.xml (No such file or directory)
15:11:32,319 ERROR [stderr] (MSC service thread 1-1) at java.io.FileInputStream?.open(Native Method)
15:11:32,345 ERROR [stderr] (MSC service thread 1-1) at java.io.FileInputStream?.<init>(FileInputStream?.java:120)
15:11:32,346 ERROR [stderr] (MSC service thread 1-1) at java.io.FileInputStream?.<init>(FileInputStream?.java:79)
15:11:32,351 ERROR [stderr] (MSC service thread 1-1) at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:70)
15:11:32,364 ERROR [stderr] (MSC service thread 1-1) at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:161)
15:11:32,365 ERROR [stderr] (MSC service thread 1-1) at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:962)

comment:3 Changed 13 years ago by dgermann

I still get a quite strange URL. But in a EJB context the method should indeed be the correct one.
Tried to move the configuration xml file to the upper most META-INF directory and then set the URL manually, but this didn't work out either.

I'll try again tomorrow, if not otherwise possible maybe initialize with default configuration so you are at least able to use it.

comment:4 Changed 13 years ago by smoser

Try that: URL url = Thread.currentThread().getContextClassLoader().getResource(LOG4J_XML);

No idea why, but works for me. Found that in Google with "DOMConfigurator.configure ejb", second link.

TODO: Set the loglevel to debug.

comment:5 Changed 13 years ago by dgermann

Well that works indeed, thanks...

Actually the log level was already on debug. Tried in TestServlet? and FlarmLoggerFactoryTest? (which worked at first where the configuration was done in FlarmLoggerFactory? class).
Doesn't matter which priority level I choose, no output happens. I will try later if that is really possible to use the domconfigurator way before the first logger is initialized.

comment:6 Changed 13 years ago by smoser

.. ok, don't spend too much time on this :-)

I'd move it back to Flarmlogger, but make sure that the initialization is done only once, implement something like:

private static boolean isInitialized = false;

public static Logger getLoggerFor(....) {
  if (!isInitialized) {
    // initialize the logger
    isInitialized = true;
  }
}

comment:7 Changed 13 years ago by smoser

Resolution: worksforme
Status: newclosed

... what a beast, works now.

Note: See TracTickets for help on using tickets.