[logback-user] Appenders

Greg Flex greg.flex at gmail.com
Tue Jun 16 20:20:41 CEST 2009


Hi Ceki,
I have a question about the LoggingEvent object.
I'd like to log some messages by "building" (populating constructor) of
LoggingEvent object, then log it with my appenders.
I saw some sample code on line and what I have at the moment is this:

Logger log;
LoggingEvent event;
Object[] args = {"test", "test2"};  //<-- I'm not sure exactly what this is
for?

event = new LoggingEvent("class", (Logger)
LoggerFactory.getLogger("SimpleSocketServer"),

Level.toLevel("DEBUG"), "test message", null, args);

log = (Logger) LoggerFactory.getLogger("testClassName");
log.callAppenders(event);

This works with my "CONSOLE" appender and I can see messages (with the
passed values) printed.
I have also a "DB" - database appender, to which I'd like to write as well,
but something doesn't work....
I see a couple of "initialization" log messages in the database, (like port
and waiting for clients to connect etc.)
but not the one I'm building myself, even though as I stated above I can see
it in the console.
What am I doing wrong?

Here is part of my config file:

<configuration>

 <appender name="DB" class="ch.qos.logback.classic.db.DBAppender">
    <connectionSource
class="ch.qos.logback.core.db.DataSourceConnectionSource">
      <dataSource class="com.mchange.v2.c3p0.ComboPooledDataSource">
         <driverClass>com.mysql.jdbc.Driver</driverClass>
          <jdbcUrl>jdbc:mysql://localhost:3306/logging</jdbcUrl>
         <user>greg</user>
         <password>greg</password>
      </dataSource>
    </connectionSource>
  </appender>

<!-- here I have simple console appender called CONSOLE-->

  <root>
    <level value ="DEBUG"/>
    <appender-ref ref="CONSOLE" />
    <appender-ref ref="DB" />
  </root>
</configuration>


UPDATE:
I just did a little test and I added an HTML FILE appender. I see all
messages there too, just like in CONSOLE appender case.
but still nothing in the database except for the initialization messages.
Any suggestions?
Thanks
Gregory.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://qos.ch/pipermail/logback-user/attachments/20090616/d1e3b721/attachment.htm>


More information about the Logback-user mailing list