You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Rakesh Patel <ra...@gmail.com> on 2006/03/17 15:19:53 UTC

Advice on auditing actions

Hi,

i have a requirement to audit events to a database table. I thought of 
using the log4j JdbcAppender to do this but the issue i have is there's 
auditing and there's debugging.

For example,

logger.debug("Value of variable is now:{}",aVariable); // this is not 
needed for auditing
logger.debug("Successful logon for username:{}",userName); // this 
should end up in the audit table

My current configuration of log4j is to declare a class-specific logger 
in each class that needs logging:

final static Logger _logger = Logger.getLogger(ReferenceDataDaoImpl.class);

I could use this logger and utilise thresholds and have audit events 
triggered by calling logger.error() but that does not seem a very clean 
approach.

Another idea is to declare an additional logger to be used for auditing:

final static Logger _logger = Logger.getLogger(ReferenceDataDaoImpl.class);
final static Logger _auditor = Logger.getLogger(ReferenceDataDaoImpl.class);

and have that logger use JdbcAppender. Or maybe one global logger for 
auditing?

What do you guys think?

Cheers

Rakesh

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Advice on auditing actions

Posted by James Stauffer <st...@gmail.com>.
  <logger name="audit">
    <appender-ref ref="AuditAppender"/>
  </logger>

  <logger name="com">
    <appender-ref ref="GeneralAppender"/>
  </logger>


On 3/19/06, Rakesh Patel <ra...@gmail.com> wrote:
> can you give an example of how the xml config file would look? Are you
> saying there's some regular expression i can take advantage of to attach
> the appropriate appender to the audit loggers?
>
> Thanks
>
> Rakesh
>
> James Stauffer wrote:
>
> >Attach one appender to the audit logger and a different category to
> >the other logger (com?)
> >
> >On 3/17/06, Rakesh Patel <ra...@gmail.com> wrote:
> >
> >
> >>so i have another logger but how do i control loggers output to a
> >>specific appender?
> >>
> >>cheers
> >>
> >>Rakesh
> >>
> >>James Stauffer wrote:
> >>
> >>
> >>
> >>>Do it like the following.  Then it will be easy to send the audit logs
> >>>to another location.
> >>>
> >>>final static Logger _logger = Logger.getLogger(ReferenceDataDaoImpl.class);
> >>>final static Logger _auditor =
> >>>Logger.getLogger("audit."ReferenceDataDaoImpl.class.getName());
> >>>
> >>>
> >>>On 3/17/06, Rakesh Patel <ra...@gmail.com> wrote:
> >>>
> >>>
> >>>
> >>>
> >>>>Hi,
> >>>>
> >>>>i have a requirement to audit events to a database table. I thought of
> >>>>using the log4j JdbcAppender to do this but the issue i have is there's
> >>>>auditing and there's debugging.
> >>>>
> >>>>For example,
> >>>>
> >>>>logger.debug("Value of variable is now:{}",aVariable); // this is not
> >>>>needed for auditing
> >>>>logger.debug("Successful logon for username:{}",userName); // this
> >>>>should end up in the audit table
> >>>>
> >>>>My current configuration of log4j is to declare a class-specific logger
> >>>>in each class that needs logging:
> >>>>
> >>>>final static Logger _logger = Logger.getLogger(ReferenceDataDaoImpl.class);
> >>>>
> >>>>I could use this logger and utilise thresholds and have audit events
> >>>>triggered by calling logger.error() but that does not seem a very clean
> >>>>approach.
> >>>>
> >>>>Another idea is to declare an additional logger to be used for auditing:
> >>>>
> >>>>final static Logger _logger = Logger.getLogger(ReferenceDataDaoImpl.class);
> >>>>final static Logger _auditor = Logger.getLogger(ReferenceDataDaoImpl.class);
> >>>>
> >>>>and have that logger use JdbcAppender. Or maybe one global logger for
> >>>>auditing?
> >>>>
> >>>>What do you guys think?
> >>>>
> >>>>Cheers
> >>>>
> >>>>Rakesh
> >>>>
> >>>>---------------------------------------------------------------------
> >>>>To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> >>>>For additional commands, e-mail: log4j-user-help@logging.apache.org
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>--
> >>>James Stauffer
> >>>Are you good? Take the test at http://www.livingwaters.com/good/
> >>>
> >>>---------------------------------------------------------------------
> >>>To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> >>>For additional commands, e-mail: log4j-user-help@logging.apache.org
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> >>For additional commands, e-mail: log4j-user-help@logging.apache.org
> >>
> >>
> >>
> >>
> >
> >
> >--
> >James Stauffer
> >Are you good? Take the test at http://www.livingwaters.com/good/
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> >For additional commands, e-mail: log4j-user-help@logging.apache.org
> >
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>


--
James Stauffer
Are you good? Take the test at http://www.livingwaters.com/good/

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Advice on auditing actions

Posted by Rakesh Patel <ra...@gmail.com>.
can you give an example of how the xml config file would look? Are you 
saying there's some regular expression i can take advantage of to attach 
the appropriate appender to the audit loggers?

Thanks

Rakesh

James Stauffer wrote:

>Attach one appender to the audit logger and a different category to
>the other logger (com?)
>
>On 3/17/06, Rakesh Patel <ra...@gmail.com> wrote:
>  
>
>>so i have another logger but how do i control loggers output to a
>>specific appender?
>>
>>cheers
>>
>>Rakesh
>>
>>James Stauffer wrote:
>>
>>    
>>
>>>Do it like the following.  Then it will be easy to send the audit logs
>>>to another location.
>>>
>>>final static Logger _logger = Logger.getLogger(ReferenceDataDaoImpl.class);
>>>final static Logger _auditor =
>>>Logger.getLogger("audit."ReferenceDataDaoImpl.class.getName());
>>>
>>>
>>>On 3/17/06, Rakesh Patel <ra...@gmail.com> wrote:
>>>
>>>
>>>      
>>>
>>>>Hi,
>>>>
>>>>i have a requirement to audit events to a database table. I thought of
>>>>using the log4j JdbcAppender to do this but the issue i have is there's
>>>>auditing and there's debugging.
>>>>
>>>>For example,
>>>>
>>>>logger.debug("Value of variable is now:{}",aVariable); // this is not
>>>>needed for auditing
>>>>logger.debug("Successful logon for username:{}",userName); // this
>>>>should end up in the audit table
>>>>
>>>>My current configuration of log4j is to declare a class-specific logger
>>>>in each class that needs logging:
>>>>
>>>>final static Logger _logger = Logger.getLogger(ReferenceDataDaoImpl.class);
>>>>
>>>>I could use this logger and utilise thresholds and have audit events
>>>>triggered by calling logger.error() but that does not seem a very clean
>>>>approach.
>>>>
>>>>Another idea is to declare an additional logger to be used for auditing:
>>>>
>>>>final static Logger _logger = Logger.getLogger(ReferenceDataDaoImpl.class);
>>>>final static Logger _auditor = Logger.getLogger(ReferenceDataDaoImpl.class);
>>>>
>>>>and have that logger use JdbcAppender. Or maybe one global logger for
>>>>auditing?
>>>>
>>>>What do you guys think?
>>>>
>>>>Cheers
>>>>
>>>>Rakesh
>>>>
>>>>---------------------------------------------------------------------
>>>>To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>>>>For additional commands, e-mail: log4j-user-help@logging.apache.org
>>>>
>>>>
>>>>
>>>>
>>>>        
>>>>
>>>--
>>>James Stauffer
>>>Are you good? Take the test at http://www.livingwaters.com/good/
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>>>For additional commands, e-mail: log4j-user-help@logging.apache.org
>>>
>>>
>>>
>>>
>>>      
>>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>>For additional commands, e-mail: log4j-user-help@logging.apache.org
>>
>>
>>    
>>
>
>
>--
>James Stauffer
>Are you good? Take the test at http://www.livingwaters.com/good/
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>
>  
>

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Advice on auditing actions

Posted by James Stauffer <st...@gmail.com>.
Attach one appender to the audit logger and a different category to
the other logger (com?)

On 3/17/06, Rakesh Patel <ra...@gmail.com> wrote:
> so i have another logger but how do i control loggers output to a
> specific appender?
>
> cheers
>
> Rakesh
>
> James Stauffer wrote:
>
> >Do it like the following.  Then it will be easy to send the audit logs
> >to another location.
> >
> >final static Logger _logger = Logger.getLogger(ReferenceDataDaoImpl.class);
> >final static Logger _auditor =
> >Logger.getLogger("audit."ReferenceDataDaoImpl.class.getName());
> >
> >
> >On 3/17/06, Rakesh Patel <ra...@gmail.com> wrote:
> >
> >
> >>Hi,
> >>
> >>i have a requirement to audit events to a database table. I thought of
> >>using the log4j JdbcAppender to do this but the issue i have is there's
> >>auditing and there's debugging.
> >>
> >>For example,
> >>
> >>logger.debug("Value of variable is now:{}",aVariable); // this is not
> >>needed for auditing
> >>logger.debug("Successful logon for username:{}",userName); // this
> >>should end up in the audit table
> >>
> >>My current configuration of log4j is to declare a class-specific logger
> >>in each class that needs logging:
> >>
> >>final static Logger _logger = Logger.getLogger(ReferenceDataDaoImpl.class);
> >>
> >>I could use this logger and utilise thresholds and have audit events
> >>triggered by calling logger.error() but that does not seem a very clean
> >>approach.
> >>
> >>Another idea is to declare an additional logger to be used for auditing:
> >>
> >>final static Logger _logger = Logger.getLogger(ReferenceDataDaoImpl.class);
> >>final static Logger _auditor = Logger.getLogger(ReferenceDataDaoImpl.class);
> >>
> >>and have that logger use JdbcAppender. Or maybe one global logger for
> >>auditing?
> >>
> >>What do you guys think?
> >>
> >>Cheers
> >>
> >>Rakesh
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> >>For additional commands, e-mail: log4j-user-help@logging.apache.org
> >>
> >>
> >>
> >>
> >
> >
> >--
> >James Stauffer
> >Are you good? Take the test at http://www.livingwaters.com/good/
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> >For additional commands, e-mail: log4j-user-help@logging.apache.org
> >
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>


--
James Stauffer
Are you good? Take the test at http://www.livingwaters.com/good/

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Advice on auditing actions

Posted by Rakesh Patel <ra...@gmail.com>.
so i have another logger but how do i control loggers output to a 
specific appender?

cheers

Rakesh

James Stauffer wrote:

>Do it like the following.  Then it will be easy to send the audit logs
>to another location.
>
>final static Logger _logger = Logger.getLogger(ReferenceDataDaoImpl.class);
>final static Logger _auditor =
>Logger.getLogger("audit."ReferenceDataDaoImpl.class.getName());
>
>
>On 3/17/06, Rakesh Patel <ra...@gmail.com> wrote:
>  
>
>>Hi,
>>
>>i have a requirement to audit events to a database table. I thought of
>>using the log4j JdbcAppender to do this but the issue i have is there's
>>auditing and there's debugging.
>>
>>For example,
>>
>>logger.debug("Value of variable is now:{}",aVariable); // this is not
>>needed for auditing
>>logger.debug("Successful logon for username:{}",userName); // this
>>should end up in the audit table
>>
>>My current configuration of log4j is to declare a class-specific logger
>>in each class that needs logging:
>>
>>final static Logger _logger = Logger.getLogger(ReferenceDataDaoImpl.class);
>>
>>I could use this logger and utilise thresholds and have audit events
>>triggered by calling logger.error() but that does not seem a very clean
>>approach.
>>
>>Another idea is to declare an additional logger to be used for auditing:
>>
>>final static Logger _logger = Logger.getLogger(ReferenceDataDaoImpl.class);
>>final static Logger _auditor = Logger.getLogger(ReferenceDataDaoImpl.class);
>>
>>and have that logger use JdbcAppender. Or maybe one global logger for
>>auditing?
>>
>>What do you guys think?
>>
>>Cheers
>>
>>Rakesh
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>>For additional commands, e-mail: log4j-user-help@logging.apache.org
>>
>>
>>    
>>
>
>
>--
>James Stauffer
>Are you good? Take the test at http://www.livingwaters.com/good/
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>
>  
>

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Advice on auditing actions

Posted by James Stauffer <st...@gmail.com>.
Do it like the following.  Then it will be easy to send the audit logs
to another location.

final static Logger _logger = Logger.getLogger(ReferenceDataDaoImpl.class);
final static Logger _auditor =
Logger.getLogger("audit."ReferenceDataDaoImpl.class.getName());


On 3/17/06, Rakesh Patel <ra...@gmail.com> wrote:
> Hi,
>
> i have a requirement to audit events to a database table. I thought of
> using the log4j JdbcAppender to do this but the issue i have is there's
> auditing and there's debugging.
>
> For example,
>
> logger.debug("Value of variable is now:{}",aVariable); // this is not
> needed for auditing
> logger.debug("Successful logon for username:{}",userName); // this
> should end up in the audit table
>
> My current configuration of log4j is to declare a class-specific logger
> in each class that needs logging:
>
> final static Logger _logger = Logger.getLogger(ReferenceDataDaoImpl.class);
>
> I could use this logger and utilise thresholds and have audit events
> triggered by calling logger.error() but that does not seem a very clean
> approach.
>
> Another idea is to declare an additional logger to be used for auditing:
>
> final static Logger _logger = Logger.getLogger(ReferenceDataDaoImpl.class);
> final static Logger _auditor = Logger.getLogger(ReferenceDataDaoImpl.class);
>
> and have that logger use JdbcAppender. Or maybe one global logger for
> auditing?
>
> What do you guys think?
>
> Cheers
>
> Rakesh
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>


--
James Stauffer
Are you good? Take the test at http://www.livingwaters.com/good/

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org