private void openLog ( ) { closeLogStream ( ) ; WriteStream os = _os ; _os = null ; IoUtil . close ( os ) ; Path path = getPath ( ) ; if ( path == null ) { path = getPath ( CurrentTime . currentTime ( ) ) ; } Path parent = path . getParent ( ) ; try { if ( ! Files . isDirectory ( parent ) ) { Files . createDirectory ( parent ) ; } } catch ( Exception e ) { logWarning ( L . l ( "Can't create log directory {0}.\n Exception={1}" , parent , e ) , e ) ; } Exception exn = null ; for ( int i = 0 ; i < 3 && _os == null ; i ++ ) { try { OutputStream out = Files . newOutputStream ( path , StandardOpenOption . APPEND ) ; _os = new WriteStream ( out ) ; } catch ( IOException e ) { exn = e ; } } String pathName = path . toString ( ) ; try { if ( pathName . endsWith ( ".gz" ) ) { _zipOut = _os ; _os = new WriteStream ( new GZIPOutputStream ( _zipOut ) ) ; } else if ( pathName . endsWith ( ".zip" ) ) { throw new ConfigException ( "Can't support .zip in path-format" ) ; } } catch ( Exception e ) { if ( exn == null ) exn = e ; } if ( exn != null ) logWarning ( L . l ( "Can't create log for {0}.\n User={1} Exception={2}" , path , System . getProperty ( "user.name" ) , exn ) , exn ) ; }
Tries to open the log . Called from inside _logLock