logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott Deboy <scott.de...@gmail.com>
Subject Re: Issue with IDField in CustomSQLDBReceiver
Date Thu, 07 Jul 2011 18:53:49 GMT
Yes, IDField is used to dynamically update the SQL statement with a 'where'
clause: (idfield) > (last known IDField value), essentially allowing it to
'tail' the table contents.

Here is the config I was able to use to get it to tail with a very simple
mysql db (verified by printing out the sql statement in the receiver..I saw
the where clause modified), and the new results were added to the table.

<?xml version="1.0" encoding="UTF-8"?>
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
debug="true">
    <plugin class="org.apache.log4j.db.CustomSQLDBReceiver" name="DB">
      <connectionSource
class="org.apache.log4j.db.DriverManagerConnectionSource">
           <param name="user" value="someusername"/>
           <param name="password" value="someuserpassword"/>
           <param name="driverClass" value="com.mysql.jdbc.Driver"/>
           <param name="url" value="jdbc:mysql://127.0.0.1:3306/test"/>
      </connectionSource>
        <param name="IDField" value="COUNTER"/>
        <param name="class" value="class
org.apache.log4j.db.CustomSQLDBReceiver"/>
        <param name="name" value="DB"/>
        <param name="paused" value="false"/>
        <param name="refreshMillis" value="1000"/>
        <param name="sql" value="select logger as LOGGER, CURRENT_TIMESTAMP
as TIMESTAMP, &quot;&quot; as LEVEL, &quot;&quot; as THREAD, message as
MESSAGE, &quot;&quot; as NDC, &quot;&quot; as MDC, &quot;&quot; as
CLASS,
&quot;&quot; as METHOD, &quot;&quot; as FILE, &quot;&quot; as LINE,
concat(&quot;{{log4jid,&quot;, COUNTER,&quot;}}&quot;) as PROPERTIES,
&quot;&quot; as THROWABLE from logging"/>
    </plugin>
</log4j:configuration>

Here is the very-basic schema I used to test:

Field   Type    Null    Key     Default Extra
COUNTER int(11) NO      PRI     NULL    auto_increment
MESSAGE varchar(1000)   YES             NULL
LOGGER  varchar(255)    YES             NULL

Scott

On Thu, Jul 7, 2011 at 8:14 AM, Amit Oberoi <aoberoi@techmahindra.com>wrote:

> All,
>
>
>
> I am using the latest developer snapshot 2.0.1 for Chainsaw V2. I have
> configured CustomSQLDBReceiver with My SQL server.
>
>
>
> My problem is every time the receiver refreshes it gets all the logs in
> the database instead of the new ones. Probably it is ignoring the
> IDField param for SQL.
>
>
>
> It is apparently looking at the IDField because it complains if I don't
> set it or have it set to a field that is not a number; however, it is
> not using it in the sql.
>
>
>
> Can anyone help in sorting this out; I'll be happy to debug and work on
> a patch in case someone points me to the code.
>
>
>
> Below is my table schema and receiver configuration.
>
>
>
> Table Schema:
>
>
>
> +------------------+-----------------+---------+---------+--------------
> -----------------------+---------------------------------------------+
>
> | Field                    | Type                  | Null     | Key
> | Default                                              | Extra
> |
>
> +------------------+-----------------+---------+---------+--------------
> -----------------------+---------------------------------------------+
>
> | COUNTER         | int(11)               | NO      | PRI      | NULL
> | auto_increment                                           |
>
> | TIMESTAMP    | timestamp       | NO      |              |
> CURRENT_TIMESTAMP              | on update CURRENT_TIMESTAMP        |
>
> | THREAD            | varchar(255)  | YES      |              | NULL
> |
> |
>
> | CLASS                | varchar(255)  | YES      |              | NULL
> |
> |
>
> | METHOD          | varchar(100)  | YES      |              | NULL
> |
> |
>
> | FILE                     | varchar(100)  | YES      |              |
> NULL                                                  |
> |
>
> | LINE                    | int(11)               | YES      |
> | NULL                                                  |
> |
>
> | PRIORITY          | varchar(50)      | YES      |              | NULL
> |
> |
>
> | LOGGER            | varchar(255)  | NO      |              | NULL
> |
> |
>
> | MESSAGE         | varchar(1000) | NO      |              | NULL
> |
> |
>
> | NDC                    | varchar(255)  | YES      |              |
> NULL                                                  |
> |
>
> | MDC                   | varchar(255)  | YES      |              | NULL
> |
> |
>
> +------------------+-----------------+---------+---------+--------------
> -----------------------+---------------------------------------------+
>
>
>
> Receiver Configuration:
>
>
>
> <plugin class="org.apache.log4j.db.CustomSQLDBReceiver" name="Receiver">
>
>       <param name="active" value="true" />
>
>       <connectionSource
> class="org.apache.log4j.db.DriverManagerConnectionSource">
>
>            <param name="user" value="user1"/>
>
>            <param name="password" value="passwd"/>
>
>            <param name="driverClass" value="org.gjt.mm.mysql.Driver"/>
>
>            <param name="url"
> value="jdbc:mysql://10.2.21.127:3306/Logs"/>
>
>       </connectionSource>
>
>       <param name="refreshMillis" value="5000"/>
>
>      <param name="sql" value='select logger as LOGGER, timestamp as
> TIMESTAMP, priority as LEVEL, thread as THREAD, message as MESSAGE, ndc
> as NDC, mdc as MDC, class as CLASS, method as METHOD, file as FILE, line
> as LINE, concat("{{application,databaselogs,hostname,mymachine,
> log4jid,", COUNTER,"}}") as PROPERTIES, "" as THROWABLE from logs'/>
>
>       <param name="IDField" value="COUNTER"/>
>
>       <param name="threshold" value="ALL" />
>
>   </plugin>
>
>
>
>
>
>
>
> Regards
>
>
>
> Amit Oberoi
>
>
>
>
> ============================================================================================================================Disclaimer:
>  This message and the information contained herein is proprietary and
> confidential and subject to the Tech Mahindra policy statement, you may
> review the policy at <a href="http://www.techmahindra.com/Disclaimer.html
> ">http://www.techmahindra.com/Disclaimer.html</a> externally and <a href="
> http://tim.techmahindra.com/Disclaimer.html">
> http://tim.techmahindra.com/Disclaimer.html</a> internally within Tech
> Mahindra.============================================================================================================================
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message