Announcement Announcement Module
Collapse
No announcement yet.
Make Logger Using AOp concept Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Make Logger Using AOp concept

    I try to save Hibernate sql queries using Log4j.

    Code:
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
    <log4j:configuration xmlns:log4j="">
    
       <appender name="appenderConsole" class="org.apache.log4j.ConsoleAppender">
           <layout class="org.apache.log4j.SimpleLayout"/>
       </appender>
    
           <appender name="appenderNormalFile" class="org.apache.log4j.RollingFileAppender">
               <param name="File" value="/logs/testRuntime.log"/>
               <param name="Append" value="true"/>
               <param name="MaxFileSize" value="2MB"/>
               <param name="MaxBackupIndex" value="1"/>
               <layout class="org.apache.log4j.PatternLayout">
                    <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
               </layout>
           </appender>
           <appender name="appenderSQLFile" class="org.apache.log4j.RollingFileAppender">
               <param name="File" value="/logs/testDataBase.log"/>
               <param name="Append" value="true"/>
               <param name="MaxFileSize" value="2MB"/>
               <param name="MaxBackupIndex" value="1"/>
               <layout class="org.apache.log4j.PatternLayout">
                   <param name="ConversionPattern" value="%d %m%n"/>
               </layout>
           </appender>     
    
       <category name="org.hibernate.SQL" additivity="false">
          <priority value="debug" />
          <appender-ref ref="appenderConsole" />
          <appender-ref ref="appenderSQLFile" />
       </category>
       <category name="org.hibernate.type" additivity="false">
           <priority value="debug" />
       <appender-ref ref="appenderConsole" />
       <appender-ref ref="appenderFileSQL" />
       </category> 
       <root>
          <priority value="info" />
          <appender-ref ref="appenderConsole" />
           <appender-ref ref="appenderFileSQL" />
       </root>
    
    </log4j:configuration>
    But i don't know how to apply AOP here.

  • #2
    What exactly do you want to do by AOP? As far as I understand you want to log hibernate sql to dedicated file. The only thing necessary for that is correct logging configuration.

    Comment

    Working...
    X