=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java 2011-04-10 13:48:29 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java 2011-04-19 14:37:25 +0000 @@ -36,13 +36,13 @@ import java.util.List; import java.util.Set; -import org.apache.log4j.Logger; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataentryform.DataEntryForm; import org.hisp.dhis.i18n.I18nService; import org.hisp.dhis.period.PeriodType; import org.hisp.dhis.source.Source; -import org.hisp.dhis.system.util.AuditLogLevel; import org.hisp.dhis.system.util.AuditLogUtil; import org.hisp.dhis.system.util.Filter; import org.hisp.dhis.system.util.FilterUtils; @@ -58,7 +58,7 @@ public class DefaultDataSetService implements DataSetService { - private Logger logger = Logger.getLogger( getClass() ); + private static final Log log = LogFactory.getLog( DefaultDataSetService.class ); // ------------------------------------------------------------------------- // Dependencies @@ -100,7 +100,7 @@ i18nService.addObject( dataSet ); - logger.log( AuditLogLevel.AUDIT_TRAIL, AuditLogUtil.logMessage( currentUserService.getCurrentUsername(), + log.info( AuditLogUtil.logMessage( currentUserService.getCurrentUsername(), AuditLogUtil.ACTION_ADD, DataSet.class.getSimpleName(), dataSet.getName() ) ); return id; @@ -110,7 +110,7 @@ { dataSetStore.updateDataSet( dataSet ); - logger.log( AuditLogLevel.AUDIT_TRAIL, AuditLogUtil.logMessage( currentUserService.getCurrentUsername(), + log.info( AuditLogUtil.logMessage( currentUserService.getCurrentUsername(), AuditLogUtil.ACTION_EDIT, DataSet.class.getSimpleName(), dataSet.getName() ) ); i18nService.verify( dataSet ); @@ -122,7 +122,7 @@ dataSetStore.deleteDataSet( dataSet ); - logger.log( AuditLogLevel.AUDIT_TRAIL, AuditLogUtil.logMessage( currentUserService.getCurrentUsername(), + log.info( AuditLogUtil.logMessage( currentUserService.getCurrentUsername(), AuditLogUtil.ACTION_DELETE, DataSet.class.getSimpleName(), dataSet.getName() ) ); } === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java 2011-03-17 22:55:56 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java 2011-04-19 14:37:25 +0000 @@ -38,13 +38,13 @@ import java.util.Set; import org.apache.commons.collections.CollectionUtils; -import org.apache.log4j.Logger; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.hisp.dhis.hierarchy.HierarchyViolationException; import org.hisp.dhis.organisationunit.comparator.OrganisationUnitLevelComparator; import org.hisp.dhis.organisationunit.comparator.OrganisationUnitNameComparator; import org.hisp.dhis.source.Source; import org.hisp.dhis.source.SourceStore; -import org.hisp.dhis.system.util.AuditLogLevel; import org.hisp.dhis.system.util.AuditLogUtil; import org.hisp.dhis.system.util.Filter; import org.hisp.dhis.system.util.FilterUtils; @@ -63,7 +63,7 @@ { private static final String LEVEL_PREFIX = "Level "; - private Logger logger = Logger.getLogger( getClass() ); + private static final Log log = LogFactory.getLog( DefaultOrganisationUnitService.class ); // ------------------------------------------------------------------------- // Dependencies @@ -105,7 +105,7 @@ int id = sourceStore.addSource( organisationUnit ); - logger.log( AuditLogLevel.AUDIT_TRAIL, AuditLogUtil.logMessage( currentUserService.getCurrentUsername(), + log.info( AuditLogUtil.logMessage( currentUserService.getCurrentUsername(), AuditLogUtil.ACTION_ADD, OrganisationUnit.class.getSimpleName(), organisationUnit.getName() ) ); return id; @@ -117,7 +117,7 @@ sourceStore.updateSource( organisationUnit ); - logger.log( AuditLogLevel.AUDIT_TRAIL, AuditLogUtil.logMessage( currentUserService.getCurrentUsername(), + log.info( AuditLogUtil.logMessage( currentUserService.getCurrentUsername(), AuditLogUtil.ACTION_EDIT, OrganisationUnit.class.getSimpleName(), organisationUnit.getName() ) ); } @@ -145,7 +145,7 @@ sourceStore.deleteSource( organisationUnit ); - logger.log( AuditLogLevel.AUDIT_TRAIL, AuditLogUtil.logMessage( currentUserService.getCurrentUsername(), + log.info( AuditLogUtil.logMessage( currentUserService.getCurrentUsername(), AuditLogUtil.ACTION_DELETE, OrganisationUnit.class.getSimpleName(), organisationUnit.getName() ) ); } === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java 2010-12-30 09:13:41 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java 2011-04-19 14:37:25 +0000 @@ -2,7 +2,10 @@ import java.util.Collection; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.system.util.AuditLogUtil; /* * Copyright (c) 2004-2010, University of Oslo @@ -38,10 +41,19 @@ public class DefaultUserService implements UserService { + private static final Log log = LogFactory.getLog( DefaultUserService.class ); + // ------------------------------------------------------------------------- // Dependencies // ------------------------------------------------------------------------- + private CurrentUserService currentUserService; + + public void setCurrentUserService( CurrentUserService currentUserService ) + { + this.currentUserService = currentUserService; + } + private UserStore userStore; public void setUserStore( UserStore userStore ) @@ -117,17 +129,32 @@ public int addUser( User user ) { + log.info( AuditLogUtil.logMessage( currentUserService.getCurrentUsername(), + AuditLogUtil.ACTION_ADD , + User.class.getSimpleName(), + user.getName()) ); + return userStore.addUser( user ); } public void deleteUser( User user ) { userStore.deleteUser( user ); + + log.info( AuditLogUtil.logMessage( currentUserService.getCurrentUsername(), + AuditLogUtil.ACTION_DELETE , + User.class.getSimpleName(), + user.getName()) ); } public void updateUser( User user ) { userStore.updateUser( user ); + + log.info( AuditLogUtil.logMessage( currentUserService.getCurrentUsername(), + AuditLogUtil.ACTION_EDIT , + User.class.getSimpleName(), + user.getName()) ); } public Collection getAllUsers() === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/hibernate/HibernateUserStore.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/hibernate/HibernateUserStore.java 2011-04-12 11:09:06 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/hibernate/HibernateUserStore.java 2011-04-19 14:37:25 +0000 @@ -32,7 +32,6 @@ import java.util.Iterator; import java.util.List; -import org.apache.log4j.Logger; import org.hibernate.Criteria; import org.hibernate.Query; import org.hibernate.Session; @@ -42,9 +41,6 @@ import org.hibernate.criterion.Restrictions; import org.hisp.dhis.common.GenericIdentifiableObjectStore; import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.system.util.AuditLogLevel; -import org.hisp.dhis.system.util.AuditLogUtil; -import org.hisp.dhis.user.CurrentUserService; import org.hisp.dhis.user.User; import org.hisp.dhis.user.UserAuthorityGroup; import org.hisp.dhis.user.UserCredentials; @@ -60,8 +56,6 @@ public class HibernateUserStore implements UserStore { - private Logger logger = Logger.getLogger( getClass() ); - // ------------------------------------------------------------------------- // Dependencies // ------------------------------------------------------------------------- @@ -73,13 +67,6 @@ this.sessionFactory = sessionFactory; } - private CurrentUserService currentUserService; - - public void setCurrentUserService( CurrentUserService currentUserService ) - { - this.currentUserService = currentUserService; - } - private GenericIdentifiableObjectStore userRoleStore; public GenericIdentifiableObjectStore getUserRoleStore() @@ -100,12 +87,6 @@ { Session session = sessionFactory.getCurrentSession(); - logger.log( AuditLogLevel.AUDIT_TRAIL, - AuditLogUtil.logMessage( currentUserService.getCurrentUsername(), - AuditLogUtil.ACTION_ADD , - User.class.getSimpleName(), - user.getName()) ); - return (Integer) session.save( user ); } @@ -114,12 +95,6 @@ Session session = sessionFactory.getCurrentSession(); session.update( user ); - - logger.log( AuditLogLevel.AUDIT_TRAIL, - AuditLogUtil.logMessage( currentUserService.getCurrentUsername(), - AuditLogUtil.ACTION_EDIT , - User.class.getSimpleName(), - user.getName()) ); } public User getUser( int id ) @@ -182,19 +157,13 @@ return query.list(); } - public void deleteUser( User user ) { Session session = sessionFactory.getCurrentSession(); session.delete( user ); - - logger.log( AuditLogLevel.AUDIT_TRAIL, - AuditLogUtil.logMessage( currentUserService.getCurrentUsername(), - AuditLogUtil.ACTION_DELETE , - User.class.getSimpleName(), - user.getName()) ); } + // ------------------------------------------------------------------------- // UserCredentials // ------------------------------------------------------------------------- === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2011-04-15 13:56:05 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2011-04-19 14:37:25 +0000 @@ -182,7 +182,6 @@ - @@ -409,6 +408,7 @@ + === removed file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/AuditLogLevel.java' --- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/AuditLogLevel.java 2011-03-02 00:04:29 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/AuditLogLevel.java 1970-01-01 00:00:00 +0000 @@ -1,136 +0,0 @@ -package org.hisp.dhis.system.util; - -/* - * Copyright (c) 2004-2010, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import org.apache.log4j.Level; - -/** - * @author Viet Nguyen - */ -public class AuditLogLevel - extends Level -{ - /** - * - */ - private static final long serialVersionUID = -4475981504189586316L; - - /** - * This value is greater than {@link org.apache.log4j.Priority#INFO_INT} - * - */ - public static final int AUDIT_TRAIL_INT = INFO_INT + 10; - - /** - * {@link Level} representing my log level - */ - public static final Level AUDIT_TRAIL = new AuditLogLevel( AUDIT_TRAIL_INT, "AUDIT_TRAIL", 7 ); - - /** - * Constructor - * - * @param arg0 - * @param arg1 - * @param arg2 - */ - protected AuditLogLevel( int arg0, String arg1, int arg2 ) - { - super( arg0, arg1, arg2 ); - - } - - /** - * Checks whether sArg is "AUDIT_TRAIL" level. If yes then - * returns {@link AuditLogLevel#AUDIT_TRAIL}, else calls - * {@link AuditLogLevel#toLevel(String, Level)} passing it - * {@link Level#DEBUG} as the defaultLevel - * - * @see Level#toLevel(java.lang.String) - * @see Level#toLevel(java.lang.String, org.apache.log4j.Level) - * - */ - public static Level toLevel( String sArg ) - { - if ( sArg != null && sArg.toUpperCase().equals( "AUDIT_TRAIL" ) ) - { - return AUDIT_TRAIL; - } - return (Level) toLevel( sArg, Level.DEBUG ); - } - - /** - * Checks whether val is {@link AuditLogLevel#AUDIT_TRAIL_INT}. - * If yes then returns {@link AuditLogLevel#AUDIT_TRAIL}, else calls - * {@link AuditLogLevel#toLevel(int, Level)} passing it {@link Level#DEBUG} - * as the defaultLevel - * - * @see Level#toLevel(int) - * @see Level#toLevel(int, org.apache.log4j.Level) - * - */ - public static Level toLevel( int val ) - { - if ( val == AUDIT_TRAIL_INT ) - { - return AUDIT_TRAIL; - } - return (Level) toLevel( val, Level.DEBUG ); - } - - /** - * Checks whether val is {@link AuditLogLevel#AUDIT_TRAIL_INT}. - * If yes then returns {@link AuditLogLevel#AUDIT_TRAIL}, else calls - * {@link Level#toLevel(int, org.apache.log4j.Level)} - * - * @see Level#toLevel(int, org.apache.log4j.Level) - */ - public static Level toLevel( int val, Level defaultLevel ) - { - if ( val == AUDIT_TRAIL_INT ) - { - return AUDIT_TRAIL; - } - return Level.toLevel( val, defaultLevel ); - } - - /** - * Checks whether sArg is "AUDIT_TRAIL" level. If yes then - * returns {@link AuditLogLevel#AUDIT_TRAIL}, else calls - * {@link Level#toLevel(java.lang.String, org.apache.log4j.Level)} - * - * @see Level#toLevel(java.lang.String, org.apache.log4j.Level) - */ - public static Level toLevel( String sArg, Level defaultLevel ) - { - if ( sArg != null && sArg.toUpperCase().equals( "AUDIT_TRAIL" ) ) - { - return AUDIT_TRAIL; - } - return Level.toLevel( sArg, defaultLevel ); - } -} === modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/WEB-INF/classes/log4j.properties' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/WEB-INF/classes/log4j.properties 2011-01-06 09:03:29 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/WEB-INF/classes/log4j.properties 2011-04-19 14:37:25 +0000 @@ -14,15 +14,6 @@ log4j.appender.console.layout = org.apache.log4j.PatternLayout log4j.appender.console.layout.ConversionPattern = * %-5p %d{ABSOLUTE} %m (%F [%t])%n -#Audit log level -log4j.appender.AUDIT=org.apache.log4j.DailyRollingFileAppender -log4j.appender.AUDIT.File= audit.log -log4j.appender.AUDIT.DatePattern='.'yyyy-MM-dd -log4j.appender.AUDIT.threshold=AUDIT_TRAIL#org.hisp.dhis.system.util.AuditLogLevel -log4j.appender.AUDIT.layout=org.apache.log4j.PatternLayout -log4j.appender.AUDIT.layout.ConversionPattern= * %-5p %d{ABSOLUTE} %m %n - # Categories (order: DEBUG, INFO, WARN, ERROR, FATAL) log4j.rootCategory = WARN, console -log4j.category.org.hisp.dhis = INFO, AUDIT -log4j.category.org.amplecode = INFO +log4j.category.org.hisp.dhis = INFO