@Test void shouldAllowLevelToBeChanged() { // Given StringWriter writer = new StringWriter(); FormattedLog log = newFormattedLog( writer, Level.INFO); // When log.info( "No, it's when there's nothing wrong with you, but you hurt anyway. You get it?" ); log.setLevel( Level.WARN ); log.info( "I know now why you cry. But it's something I can never do." ); log.setLevel( Level.DEBUG ); log.info( "There's 215 bones in the human body. That's one." ); // Then assertThat( writer.toString(), equalTo( format( "%s%n%s%n", "1984-10-26 04:23:24.343+0000 INFO [test] No, it's when there's nothing wrong with you, but " + "you hurt anyway. You get it?", "1984-10-26 04:23:24.343+0000 INFO [test] There's 215 bones in the human body. That's one." ) ) ); }
public SecurityLog( Config config, FileSystemAbstraction fileSystem, Executor executor ) throws IOException { ZoneId logTimeZoneId = config.get( GraphDatabaseSettings.db_timezone ).getZoneId(); File logFile = config.get( SecuritySettings.security_log_filename ); FormattedLog.Builder builder = FormattedLog.withZoneId( logTimeZoneId ); rotatingSupplier = new RotatingFileOutputStreamSupplier( fileSystem, logFile, config.get( SecuritySettings.store_security_log_rotation_threshold ), config.get( SecuritySettings.store_security_log_rotation_delay ).toMillis(), config.get( SecuritySettings.store_security_log_max_archives ), executor ); FormattedLog formattedLog = builder.toOutputStream( rotatingSupplier ); formattedLog.setLevel( config.get( SecuritySettings.security_log_level ) ); this.inner = formattedLog; }