eclipse-ee4j / glassfish

Eclipse GlassFish
https://eclipse-ee4j.github.io/glassfish/
386 stars 145 forks source link

Ability to log to SLF4J #6666

Closed glassfishrobot closed 4 years ago

glassfishrobot commented 16 years ago

I'm trying to get Glassfish to log to slf4j instead of Java Logging but I've run into a dead end: http://forums.java.net/jive/thread.jspa?threadID=52441&tstart=30

It would be great if the Glassfish logging mechanism was plugable or at the very least if I could somehow get access to the original System.out object to pass into slf4j.

Environment

Operating System: All Platform: All

Affected Versions

[9.1peur2]

glassfishrobot commented 6 years ago
glassfishrobot commented 15 years ago

@glassfishrobot Commented niklash said:

glassfishrobot commented 13 years ago

@glassfishrobot Commented cowwoc said: Can someone from the Glassfish team please comment on this issue?

glassfishrobot commented 13 years ago

@glassfishrobot Commented cowwoc said: http://hwellmann.blogspot.com/2010/12/glassfish-logging-with-slf4j-part-2.html contains a workaround for redirecting all Glassfish logs onto slf4j. I'm still looking for a way to redirect on a per-webapp basis.

glassfishrobot commented 13 years ago

@glassfishrobot Commented cinhtau said: Per webapp basis you have to put an independent logback.xml and invoke JoranConfigurator directly. That's the trick. See http://logback.qos.ch/manual/configuration.html

glassfishrobot commented 13 years ago

@glassfishrobot Commented cowwoc said: I understand, but you're still requiring me to place slf4j libraries in the global location and hook all java.util.logging instances to slf4j whether they want it or not.

glassfishrobot commented 12 years ago

@glassfishrobot Commented orair said: If the logging libraries are on a shared place, configure Glassfish per webapp basis will probably need to create contexts. See http://logback.qos.ch/manual/loggingSeparation.html#ContextJNDISelector for more information.

glassfishrobot commented 12 years ago

@glassfishrobot Commented tmueller said: Bulk update to change fix version to "not determined" for all issues still open but with a fix version for a released version.

glassfishrobot commented 12 years ago

@glassfishrobot Commented cowwoc said: I ended up redirecting slf4j to java.util.logging (JUL). To do this simply use slf4j-jdk14 as your logger implementation in place of logback. Unfortunately, this trades off one problem for another.

On the one hand, your logging is unified. On the other hand, you inherit all the problems associated with JUL. You cannot use any logback-specific features. You cannot use logback.xml to configure your logging. In fact, you cannot even configure different logging rules per webapp (see #18776). I ended up with the following code in my ServletContextListener:

@Override
public void contextInitialized(ServletContextEvent servletContextEvent)
{
  super.contextInitialized(servletContextEvent);

  // WORKAROUND: http://java.net/jira/browse/GLASSFISH-18776
  java.util.logging.Logger.getLogger("com.foo.bar").setLevel(Level.ALL);
}

It doesn't solve the problem of all webapps sharing the same logging configuration, but at least now the configuration is packaged in the webapp itself (as opposed to logging.properties in Glassfish's installation directory).

glassfishrobot commented 12 years ago

@glassfishrobot Commented jthoennes said: We managed to deploy SLF4J as an OSGi bundle. So you can deploy it in the normal way instead of in the lib directory. And the configuration could be done in the bundle activator.

glassfishrobot commented 16 years ago

@glassfishrobot Commented Was assigned to naman_mehta

glassfishrobot commented 7 years ago

@glassfishrobot Commented This issue was imported from java.net JIRA GLASSFISH-6666

glassfishrobot commented 16 years ago

@glassfishrobot Commented Reported by cowwoc@java.net

github-actions[bot] commented 4 years ago

This issue has been marked as inactive and old and will be closed in 7 days if there is no further activity. If you want the issue to remain open please add a comment