Login IP remote in the logs Log4J

Discussion in 'Ruby' started by Miguelon cosapi data, Nov 28, 2006.

  1. Hello friends, I hope can help me with the following thing: I have an
    application that uses the "Log4J", which I want to know is that
    line I must add so that also it registers the IP address of the clients
    who accede to this aplicaion. At the moment this recording date and URL
    but I need remote IP address. thanks
    Miguelon cosapi data, Nov 28, 2006
    #1
    1. Advertising

  2. Hello Paul
    The application is "Critical Path" and is a Mail server in the Linux
    with Webmail, calendar, etc. this is based on a called file
    "log-conf.xml" that this in the format "Log4j" the information
    that registers to me is the following:

    2006-11-16 11:36:53,851 - sid[1163694663376]
    thread[http-443-Processor86] dir[0/0, 0, 0, 0] time[62]
    url[/cp/ps/Mail/ViewMsgController?d=congreso.gob.pe&u=fondoeditorial&an=DefaultMailAccount&t=d104d&l=es&fp=INBOX&uid=98]
    2006-11-16 11:37:11,283 - sid[1163694663376]
    thread[http-443-Processor13] dir[0/0, 0, 0, 0] time[157]
    url[/cp/ps/Mail/ViewMsgController?d=congreso.gob.pe&bid=null_0&u=fondoeditorial&t=d104d&l=es&siz=38278]
    2006-11-16 11:37:27,892 - sid[1163695047890]
    thread[http-443-Processor85] dir[0/0, 0, 0, 0] time[4]
    url[/cp/ps/Main/login/Login?d=congreso.gob.pe&l=es]
    2006-11-16 11:37:34,478 - sid[1163695047890]
    thread[http-443-Processor13] dir[1/5, 0, 1, 0] time[4]
    url[/cp/ps/Main/layout/MetaFrameset?d=congreso.gob.pe&u=emendez&t=d10d5&l=es]

    what I need is that additional to that information IP address of the
    client is added who connects itself to the server.

    the configuration of "log-conf.xml" is the following:

    <?xml version="1.0" encoding="UTF-8" ?>

    <!--
    - Logging configuration; see the Log4J docs and log4j.dtd for
    details
    - of this file's format and content.
    -->

    <!--
    The following log levels are supported, they are listed in
    order of precedence:

    Disable - DISABLE
    Emergency - EMERGENCY
    Alert - ALERT
    Critical - CRITICAL
    Fatal - FATAL
    Error - ERROR
    Warning - WARN
    Notice - NOTICE
    Information - INFO
    Debug - DEBUG
    All - ALL
    -->

    <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

    <log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>

    <!--
    ====================================================================
    Appender declarations -->

    <!-- Presentation Server log appender -->
    <appender name="ps-log"
    class="net.cp.ps.sdk.util.log.RollingFileAppender">
    <param name="File" value="WEB-INF/log-files/server.log"/>
    <param name="MaxFileSize" value="1MB"/>
    <param name="MaxBackupIndex" value="1"/>
    <layout class="org.apache.log4j.PatternLayout">
    <param name="ConversionPattern" value="%d %-5p %c{1} - %m%n"/>
    </layout>
    </appender>
    <!-- Presentation Server Access log appender -->
    <appender name="access-log"
    class="net.cp.ps.sdk.util.log.RollingFileAppender">
    <param name="File" value="WEB-INF/log-files/access.log"/>

    <param name="MaxFileSize" value="100MB"/>
    <param name="MaxBackupIndex" value="20"/>
    <layout class="org.apache.log4j.PatternLayout">
    <param name="ConversionPattern" value="%d - %m%n"/>
    </layout>
    </appender>

    <!-- Presentation Server Slow Request log appender -->
    <appender name="slow-log"
    class="net.cp.ps.sdk.util.log.RollingFileAppender">
    <param name="File" value="WEB-INF/log-files/slow.log"/>
    <param name="MaxFileSize" value="1MB"/>
    <param name="MaxBackupIndex" value="20"/>
    <layout class="org.apache.log4j.PatternLayout">
    <param name="ConversionPattern" value="%d %-5p - %m%n"/>
    </layout>
    </appender>

    <!-- Downloader appender. -->
    <appender name="downloader-log"
    class="net.cp.ps.sdk.util.log.RollingFileAppender">
    <param name="File" value="WEB-INF/log-files/downloader.log"/>
    <param name="MaxFileSize" value="1MB"/>
    <param name="MaxBackupIndex" value="1"/>
    <layout class="org.apache.log4j.PatternLayout">
    <param name="ConversionPattern" value="%d %-5p %c{1} - %m%n"/>
    </layout>
    </appender>

    <!-- Begin Fix 39570 -->
    <!-- Mail appender -->
    <appender name="mail-log"
    class="net.cp.ps.sdk.util.log.RollingFileAppender">
    <param name="File" value="WEB-INF/log-files/mail.log" />
    <param name="MaxFileSize" value="1MB" />
    <param name="MaxBackupIndex" value="1" />
    <layout class="org.apache.log4j.PatternLayout">
    <param name="ConversionPattern" value="%d %-5p %c{1} -%m%n"
    />
    </layout>
    </appender>

    <!-- End Fix 39570 -->

    <appender name="cal-log"
    class="net.cp.ps.sdk.util.log.RollingFileAppender">
    <param name="File" value="WEB-INF/log-files/cal.log"/>
    <param name="MaxFileSize" value="1MB"/>
    <param name="MaxBackupIndex" value="1"/>
    <layout class="org.apache.log4j.PatternLayout">
    <param name="ConversionPattern" value="%d %-5p
    %c{1} - %m%n"/>
    </layout>
    </appender>
    <appender name="pab-log"
    class="net.cp.ps.sdk.util.log.RollingFileAppender">
    <param name="File" value="WEB-INF/log-files/pab.log"/>
    <param name="MaxFileSize" value="1MB"/>
    <param name="MaxBackupIndex" value="1"/>
    <layout class="org.apache.log4j.PatternLayout">
    <param name="ConversionPattern" value="%d %-5p
    %c{1} - %m%n"/>
    </layout>
    </appender>
    <appender name="ac-log"
    class="net.cp.ps.sdk.util.log.RollingFileAppender">
    <param name="File" value="WEB-INF/log-files/ac.log"/>
    <param name="MaxFileSize" value="1MB"/>
    <param name="MaxBackupIndex" value="1"/>
    <layout class="org.apache.log4j.PatternLayout">
    <param name="ConversionPattern" value="%d %-5p
    %c{1} - %m%n"/>
    </layout>
    </appender>
    <!-- Log appender for everything not otherwise directed -->
    <appender name="sys-log"
    class="net.cp.ps.sdk.util.log.RollingFileAppender">
    <param name="File" value="WEB-INF/log-files/system.log"/>
    <param name="MaxFileSize" value="1MB"/>
    <param name="MaxBackupIndex" value="1"/>
    <layout class="org.apache.log4j.PatternLayout">
    <param name="ConversionPattern" value="%d %-5p %c - %m%n"/>
    </layout>
    </appender>

    <!--
    ====================================================================
    Attach appenders to appropriate categories -->

    <!-- Presentation Server -->

    <category name="net.cp.ps.sdk" additivity="false">
    <priority class="net.cp.ps.sdk.util.log.LogLevel" value="info"/>
    <appender-ref ref="ps-log"/>
    </category>

    <category name="net.cp.ps.log.Access" additivity="false">
    <priority class="net.cp.ps.sdk.util.log.LogLevel" value="info"/>
    <appender-ref ref="access-log"/>
    </category>

    <category name="net.cp.ps.sdk.tools.monitor.request.RequestWatcher"
    additivity="false">
    <priority class="net.cp.ps.sdk.util.log.LogLevel" value="info"/>
    <appender-ref ref="slow-log"/>
    </category>

    <category name="net.cp.ps.sdk.downloader" additivity="false">
    <priority class="net.cp.ps.sdk.util.log.LogLevel" value="info"/>
    <appender-ref ref="downloader-log"/>
    </category>

    <category name="net.cp.ps.main" additivity="false">
    <priority class="net.cp.ps.sdk.util.log.LogLevel" value="info"/>
    <appender-ref ref="ps-log"/>
    </category>

    <category name="net.cp.ps.uikit" additivity="false">
    <priority class="net.cp.ps.sdk.util.log.LogLevel" value="info"/>
    <appender-ref ref="ps-log"/>
    </category>

    <category name="net.cp.ps.provision" additivity="false">
    <priority class="net.cp.ps.sdk.util.log.LogLevel" value="info"/>
    <appender-ref ref="ps-log"/>
    </category>

    <!-- Begin Fix 39570 -->
    <category name="net.cp.ps.mail" additivity="false">
    <priority class="net.cp.ps.sdk.util.log.LogLevel" value="info"
    />
    <appender-ref ref="mail-log" />
    </category>
    <!-- End Fix 39570 -->

    <!-- Supress verbose debug output from Settings class. -->
    <category name="net.cp.ps.sdk.settings.Settings">
    <priority class="net.cp.ps.sdk.util.log.LogLevel" value="info" />
    </category>

    <!-- Supress verbose debug output from TimerDirContext class. -->
    <category name="net.cp.ps.sdk.util.jndi.timer.TimerDirContext">
    <priority class="net.cp.ps.sdk.util.log.LogLevel" value="info" />
    </category>

    <!-- Ensure that unhandled exception error reporting is left on -->
    <category name="net.cp.ps.sdk.http.JSPProcessor">
    <priority class="net.cp.ps.sdk.util.log.LogLevel" value="error"/>
    </category>

    <!-- Catch-all: any logging from unmapped categories -->

    <root>
    <priority class="net.cp.ps.sdk.util.log.LogLevel" value="info" />
    <appender-ref ref="sys-log" />
    </root>

    <category name="net.cp.ps.calendar" additivity="false">
    <priority class="net.cp.ps.sdk.util.log.LogLevel"
    value="info"/>
    <appender-ref ref="cal-log"/>
    </category>


    <category name="net.jlibical" additivity="false">
    <priority class="net.cp.ps.sdk.util.log.LogLevel"
    value="info"/>
    <appender-ref ref="cal-log"/>
    </category>
    <category name="net.cp.ps.pspab" additivity="false">
    <priority class="net.cp.ps.sdk.util.log.LogLevel"
    value="info"/>
    <appender-ref ref="pab-log"/>
    </category>


    <category name="net.cp.client.pab" additivity="false">
    <priority class="net.cp.ps.sdk.util.log.LogLevel"
    value="info"/>
    <appender-ref ref="pab-log"/>
    </category>

    <category name="net.cp.client.pspab" additivity="false">
    <priority class="net.cp.ps.sdk.util.log.LogLevel"
    value="info"/>
    <appender-ref ref="pab-log"/>
    </category>

    <category name="net.cp.ps.directory" additivity="false">
    <priority class="net.cp.ps.sdk.util.log.LogLevel"
    value="info"/>
    <appender-ref ref="pab-log"/>
    </category>
    <category name="net.cp.ps.ac" additivity="false">
    <priority class="net.cp.ps.sdk.util.log.LogLevel"
    value="info"/>
    <appender-ref ref="ac-log"/>
    </category>
    </log4j:configuration>


    The file for login acces is: WEB-INF/log-files/access.log

    thanks.

    Paul Lutus ha escrito:

    > Miguelon cosapi data wrote:
    >
    > > Hello friends, I hope can help me with the following thing: I have an
    > > application that uses the "Log4J", which I want to know is that
    > > line I must add so that also it registers the IP address of the clients
    > > who accede to this aplicaion. At the moment this recording date and URL
    > > but I need remote IP address.

    >
    > The answer depends on information not provided. What kind of application is
    > it? What does it do?
    >
    > --
    > Paul Lutus
    > http://www.arachnoid.com
    Miguelon cosapi data, Nov 28, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alexandra Stehman

    eclipse, junit, log4j, & finding log4j.xml

    Alexandra Stehman, Jan 19, 2004, in forum: Java
    Replies:
    0
    Views:
    5,758
    Alexandra Stehman
    Jan 19, 2004
  2. Arvind
    Replies:
    2
    Views:
    13,449
    Rajesh Tihari
    May 24, 2004
  3. Alex Hunsley
    Replies:
    2
    Views:
    12,914
    =?ISO-8859-15?Q?Fr=E9d=E9ric_G=E9din?=
    May 28, 2004
  4. Rodolfo
    Replies:
    0
    Views:
    946
    Rodolfo
    Jul 12, 2004
  5. joes
    Replies:
    1
    Views:
    2,122
Loading...

Share This Page