← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18923: Added a root logger to DHIS2_HOME/logs/dhis.log in Log4JLogConfigInitializer

 

------------------------------------------------------------
revno: 18923
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-04-16 10:27:02 +0200
message:
  Added a root logger to DHIS2_HOME/logs/dhis.log in Log4JLogConfigInitializer
modified:
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalServiceTest.java
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/log/Log4JLogConfigInitializer.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalServiceTest.java	2015-04-16 00:11:41 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalServiceTest.java	2015-04-16 08:27:02 +0000
@@ -521,7 +521,6 @@
         assertNull( level );
     }
 
-    @Ignore //TODO enable, fails randomly with DataMayNotBeApprovedException
     @Test
     public void testAddDuplicateDataApproval() throws Exception
     {
@@ -545,7 +544,6 @@
         dataApprovalService.approveData( asList( dataApprovalB ) ); // Redundant, so call is ignored.
     }
 
-    @Ignore //TODO enable, fails randomly with DataMayNotBeApprovedException
     @Test
     public void testDeleteDataApproval() throws Exception
     {
@@ -1232,7 +1230,6 @@
         assertFalse( dataApprovalService.getDataApprovalStatusAndPermissions( dataSetA, periodA, organisationUnitF, defaultCombo ).getPermissions().isMayUnapprove());
     }
 
-    @Ignore //Enable this test, fails at line 1270 randomly
     @Test
     public void testMayUnapproveWithAcceptAuthority() throws Exception
     {

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/log/Log4JLogConfigInitializer.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/log/Log4JLogConfigInitializer.java	2015-04-15 14:58:13 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/log/Log4JLogConfigInitializer.java	2015-04-16 08:27:02 +0000
@@ -50,12 +50,12 @@
 {    
     private static final PatternLayout PATTERN_LAYOUT = new PatternLayout( "* %-5p %d{ISO8601} %m (%F [%t])%n" );
     
-    private static final String MAX_FILE_SIZE = "25MB";
-    private static final int MAX_BACKUP_FILES = 3;
+    private static final String MAX_FILE_SIZE = "50MB";
 
     private static final String LOG_DIR = "logs";
     private static final String ANALYTICS_TABLE_LOGGER_FILENAME = "dhis-analytics-table.log";
     private static final String DATA_SYNC_LOGGER_FILENAME = "dhis-data-sync.log";
+    private static final String GENERAL_LOGGER_FILENAME = "dhis.log";
 
     private static final Log log = LogFactory.getLog( Log4JLogConfigInitializer.class );
     
@@ -76,6 +76,8 @@
         configureLoggers( ANALYTICS_TABLE_LOGGER_FILENAME, Lists.newArrayList( "org.hisp.dhis.resourcetable", "org.hisp.dhis.analytics.table" ) );
         
         configureLoggers( DATA_SYNC_LOGGER_FILENAME, Lists.newArrayList( "org.hisp.dhis.dxf2.synch" ) );
+        
+        configureRootLogger( GENERAL_LOGGER_FILENAME );
     }
     
     /**
@@ -101,6 +103,22 @@
     }
     
     /**
+     * Configures a root file logger.
+     * 
+     * @param filename the filename to output logging to.
+     */
+    private void configureRootLogger( String filename )
+    {
+        String file = getLogFile( filename );
+        
+        RollingFileAppender appender = getRollingFileAppender( file );
+        
+        Logger.getRootLogger().addAppender( appender );
+        
+        log.info( "Added root logger using file: " + file );
+    }
+    
+    /**
      * Returns a rolling file appender.
      * 
      * @param file the file to output to, including path and filename.
@@ -112,7 +130,6 @@
         appender.setThreshold( Level.INFO );
         appender.setFile( file );
         appender.setMaxFileSize( MAX_FILE_SIZE );
-        appender.setMaxBackupIndex( MAX_BACKUP_FILES );
         appender.setLayout( PATTERN_LAYOUT );
         appender.activateOptions();