-
1. Custom logger on AS 6
nickarls Mar 17, 2011 3:53 AM (in response to nickarls)If I make a typo in the class name the AS reacts so I guess the class is picked up. It's not just getting any action. And the documentation on loggers on AS 6 was a bit...thin that last time I checked...
-
2. Re: Custom logger on AS 6
jaikiran Mar 17, 2011 6:25 AM (in response to nickarls)Just to check whether it's the logging level which is preventing the call to your append method, try adding this method to that appender:
@Override public void doAppend(LoggingEvent event) { System.out.println("Custom appender invoked"); super.doAppend(event); }
-
3. Re: Custom logger on AS 6
nickarls Mar 17, 2011 6:38 AM (in response to jaikiran)I don't get any output, I've tried fiddling with most thresholds I could find...
-
4. Re: Custom logger on AS 6
nickarls Mar 20, 2011 8:05 AM (in response to nickarls)Does anyone have an example of a custom logger + jboss-logging.xml that shows how the log levels are set up (and info on if you use jboss logging, slf4j or what for application logging)?
-
5. Re: Custom logger on AS 6
nickarls Mar 20, 2011 4:22 PM (in response to nickarls)I tried uncommenting the SMTP logger, add the handler ref to the root logger and set it's threshold to INFO for a boot. I didn't get any warnings about wrong mail server etc (kept the default values).
-
6. Re: Custom logger on AS 6
nickarls Mar 22, 2011 3:25 AM (in response to nickarls)log4j appender? working? anyone?
-
7. Re: Custom logger on AS 6
jaikiran Mar 22, 2011 3:44 AM (in response to nickarls)Let me give it a try this week, if no else gets there by then. If you have something ready that I can easily test/reuse, please attach it here.
-
8. Re: Custom logger on AS 6
nickarls Mar 22, 2011 5:41 PM (in response to jaikiran)I have a dummy logger (attached) that basically just does
public class DummyLogger extends AppenderSkeleton
{
public void close()
{
}
public boolean requiresLayout()
{
return true;
}
@Override
protected void append(LoggingEvent event)
{
System.out.println("Custom appender invoked");
super.doAppend(event);
}
}
I add it to the root logger (copied from SMTP definition) and logging shows up for console and file but nothing from here. FQCN is jboss.logtest.DummyLogger
-
logger-1.0.0-SNAPSHOT.jar 2.1 KB
-
-
9. Re: Custom logger on AS 6
jaikiran Mar 23, 2011 7:00 AM (in response to nickarls)There is more than one issue in here.
1) jboss-logmanager doesn't report a error which makes it look like the appender is just not picked up. org.jboss.logmanager.LoggerNode has this:
void publish(final ExtLogRecord record) { for (Handler handler : handlers) try { handler.publish(record); } catch (VirtualMachineError e) { throw e; } catch (Throwable t) { // todo - error handler } if (useParentHandlers) { final LoggerNode parent = this.parent; if (parent != null) parent.publish(record); } }
Notice the Throwable catch block. That's where it's ending up currently.
2) The real issue is that the jboss-logmanager-log4j project is incompatible with the version of log4j (1.2.14) that's shipped in JBoss AS. The jboss-logmanager-log4j requires 1.2.15 http://anonsvn.jboss.org/repos/common/jboss-logmanager-log4j/trunk/pom.xml and runs into a:
16:17:24,763 ERROR [STDERR] java.lang.NoSuchMethodError: org.apache.log4j.spi.LoggingEvent.<init>(Ljava/lang/String;Lorg/apache/log4j/Category;JLorg/apache/log4j/Level;Ljava/lang/Object;Ljava/lang/String;Lorg/apache/log4j/spi/ThrowableInformation;Ljava/lang/String;Lorg/apache/log4j/spi/LocationInfo;Ljava/util/Map;)V
in the org.jboss.logmanager.log4j.ConvertedLoggingEvent constructor:
public final class ConvertedLoggingEvent extends LoggingEvent { ... public ConvertedLoggingEvent(final ExtLogRecord rec) { super(rec.getLoggerClassName(), new DummyCategory(rec.getLoggerName()), rec.getMillis(), LevelMapping.getPriorityFor(rec.getLevel()), rec.getMessage(), rec.getThreadName(), rec.getThrown() == null ? null : new ThrowableInformation(rec.getThrown()), rec.getNdc(), new LocationInfo(new Throwable(), rec.getLoggerClassName()), null); }
As a workaround, replace the log4j.jar in JBOSS_HOME/common/lib with 1.2.15 version of log4j.jar and see if it works.
Ah, all these logging frameworks and abstractions - so much fun!
-
10. Re: Custom logger on AS 6
nickarls Mar 23, 2011 7:06 AM (in response to jaikiran)*facepalm* Well, good thing is not just me ;-)
Empty catch blocks are always nice. e.printStackTrace() is so hard to type...
We need some abstraction for logger abstraction-abstractions. I'll try the log4j replacement trick and let you know. Was there some JIRA born from this?
-
11. Re: Custom logger on AS 6
jaikiran Mar 23, 2011 7:13 AM (in response to nickarls)Nicklas Karlsson wrote:
Was there some JIRA born from this?
Haven't yet created one (been busy with a different task). So if you have some time, do create one. Else, I'll do it later tonight.
-
12. Re: Custom logger on AS 6
nickarls Mar 23, 2011 8:16 AM (in response to jaikiran)Upgrading log4j didn't work. Well, I should really try on a clean server to make sure I haven't broken something else while trying to fix this...
-
13. Re: Custom logger on AS 6
nickarls Mar 23, 2011 8:24 AM (in response to nickarls)Correction, now I get hits on the logger!
-
14. Custom logger on AS 6
jaikiran Mar 24, 2011 3:16 AM (in response to nickarls)Nicklas Karlsson wrote:
Correction, now I get hits on the logger!
Thanks for verifying that. So I guess, the easiest way to fix this is to upgrade to 1.2.15 of log4j in JBoss AS6. I'll file a JIRA for that.