org.neo4j.kernel.configuration.Config.setLogger()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(144)

本文整理了Java中org.neo4j.kernel.configuration.Config.setLogger()方法的一些代码示例,展示了Config.setLogger()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Config.setLogger()方法的具体详情如下:
包路径:org.neo4j.kernel.configuration.Config
类名称:Config
方法名:setLogger

Config.setLogger介绍

[英]Specify a log where errors and warnings will be reported. Log messages that happens prior to setting a logger will be buffered and replayed onto the first logger that is set.
[中]指定将报告错误和警告的日志。设置记录器之前发生的日志消息将被缓冲并重放到设置的第一个记录器上。

代码示例

代码示例来源:origin: neo4j/neo4j

@Test
public void mustNotWarnAboutDuplicateJvmAdditionalSettings() throws Exception
{
  Log log = mock( Log.class );
  File confFile = testDirectory.createFile( "test.conf" );
  Files.write( confFile.toPath(), Arrays.asList(
      ExternalSettings.additionalJvm.name() + "=-Dsysprop=val",
      ExternalSettings.additionalJvm.name() + "=-XX:+UseG1GC",
      ExternalSettings.additionalJvm.name() + "=-XX:+AlwaysPreTouch" ) );
  Config config = Config.fromFile( confFile ).build();
  config.setLogger( log );
  // The ExternalSettings.additionalJvm setting is allowed to be specified more than once.
  verifyNoMoreInteractions( log );
}

代码示例来源:origin: neo4j/neo4j

@Test
public void shouldLogIfConfigFileCouldNotBeRead() throws IOException
{
  Log log = mock( Log.class );
  File confFile = testDirectory.file( "test.conf" );
  assertTrue( confFile.createNewFile() );
  assumeTrue( confFile.setReadable( false ) );
  Config config = Config.fromFile( confFile ).withNoThrowOnFileLoadFailure().build();
  config.setLogger( log );
  verify( log ).error( "Unable to load config file [%s]: %s", confFile, confFile + " (Permission denied)" );
}

代码示例来源:origin: neo4j/neo4j

@Test
public void shouldLogIfConfigFileCouldNotBeFound()
{
  Log log = mock( Log.class );
  File confFile = testDirectory.file( "test.conf" ); // Note: we don't create the file.
  Config config = Config.fromFile( confFile ).withNoThrowOnFileLoadFailure().build();
  config.setLogger( log );
  verify( log ).warn( "Config file [%s] does not exist.", confFile );
}

代码示例来源:origin: neo4j/neo4j

@Test
public void updateDynamicShouldLogExceptionsFromUpdateListeners()
{
  Config config = Config.builder().withConfigClasses( singletonList( new MyDynamicSettings() ) ).build();
  IllegalStateException exception = new IllegalStateException( "Boo" );
  config.registerDynamicUpdateListener( MyDynamicSettings.boolSetting, ( a, b ) ->
  {
    throw exception;
  } );
  Log log = mock( Log.class );
  config.setLogger( log );
  String settingName = MyDynamicSettings.boolSetting.name();
  config.updateDynamicSetting( settingName, "", ORIGIN );
  verify( log ).error( "Failure when notifying listeners after dynamic setting change; " +
             "new setting might not have taken effect: Boo", exception );
}

代码示例来源:origin: neo4j/neo4j

config.setLogger( log );

代码示例来源:origin: neo4j/neo4j

@Test
public void updateDynamicShouldLogChanges()
{
  String settingName = MyDynamicSettings.boolSetting.name();
  String changedMessage = "Setting changed: '%s' changed from '%s' to '%s' via '%s'";
  Config config = Config.builder().withConfigClasses( singletonList( new MyDynamicSettings() ) ).build();
  Log log = mock( Log.class );
  config.setLogger( log );
  config.updateDynamicSetting( settingName, "false", ORIGIN );
  config.updateDynamicSetting( settingName, "true", ORIGIN );
  config.updateDynamicSetting( settingName, "", ORIGIN );
  InOrder order = inOrder( log );
  order.verify( log ).info( changedMessage, settingName, "default (true)", "false", "test" );
  order.verify( log ).info( changedMessage, settingName, "false", "true", "test" );
  order.verify( log ).info( changedMessage, settingName, "true", "default (true)", "test" );
  verifyNoMoreInteractions( log );
}

代码示例来源:origin: neo4j/neo4j

@Test
public void shouldWarnAndDiscardUnknownOptionsInReservedNamespaceAndPassOnBufferedLogInWithMethods() throws Exception
{
  // Given
  Log log = mock( Log.class );
  File confFile = testDirectory.file( "test.conf" );
  assertTrue( confFile.createNewFile() );
  Config config = Config.fromFile( confFile )
             .withSetting( GraphDatabaseSettings.strict_config_validation, "false" )
             .withSetting( "ha.jibberish", "baah" )
             .withSetting( "dbms.jibberish", "booh" ).build();
  // When
  config.setLogger( log );
  config.augment( "causal_clustering.jibberish", "baah" );
  // Then
  verify( log ).warn( "Unknown config option: %s", "dbms.jibberish" );
  verify( log ).warn( "Unknown config option: %s", "ha.jibberish" );
  verifyNoMoreInteractions( log );
}

代码示例来源:origin: neo4j/neo4j

dependencies = dependencies.userLogProvider( userLogProvider );
log = userLogProvider.getLog( getClass() );
config.setLogger( log );

代码示例来源:origin: neo4j/neo4j

@Test
public void mustWarnIfFileContainsDuplicateSettings() throws Exception
{
  Log log = mock( Log.class );
  File confFile = testDirectory.createFile( "test.conf" );
  Files.write( confFile.toPath(), Arrays.asList(
      ExternalSettings.initialHeapSize.name() + "=5g",
      ExternalSettings.initialHeapSize.name() + "=4g",
      ExternalSettings.initialHeapSize.name() + "=3g",
      ExternalSettings.maxHeapSize.name() + "=10g",
      ExternalSettings.maxHeapSize.name() + "=10g" ) );
  Config config = Config.fromFile( confFile ).build();
  config.setLogger( log );
  // We should only log the warning once for each.
  verify( log ).warn( "The '%s' setting is specified more than once. Settings only be specified once, to avoid ambiguity. " +
          "The setting value that will be used is '%s'.",
      ExternalSettings.initialHeapSize.name(), "5g" );
  verify( log ).warn( "The '%s' setting is specified more than once. Settings only be specified once, to avoid ambiguity. " +
          "The setting value that will be used is '%s'.",
      ExternalSettings.maxHeapSize.name(), "10g" );
}

代码示例来源:origin: neo4j/neo4j

@Test
public void shouldLogDeprecationWarnings() throws Exception
{
  // Given
  Log log = mock( Log.class );
  File confFile = testDirectory.file( "test.conf" );
  assertTrue( confFile.createNewFile() );
  Config config = Config.fromFile( confFile )
             .withSetting( MySettingsWithDefaults.oldHello, "baah" )
             .withSetting( MySettingsWithDefaults.oldSetting, "booh" )
             .withConfigClasses( Arrays.asList( mySettingsWithDefaults, myMigratingSettings,
                 new GraphDatabaseSettings() ) )
             .build();
  // When
  config.setLogger( log );
  // Then
  verify( log ).warn( "%s is deprecated. Replaced by %s", MySettingsWithDefaults.oldHello.name(),
      MySettingsWithDefaults.hello.name() );
  verify( log ).warn( "%s is deprecated.", MySettingsWithDefaults.oldSetting.name() );
  verifyNoMoreInteractions( log );
}

代码示例来源:origin: neo4j/neo4j

public CommunityNeoServer build() throws IOException
{
  if ( dataDir == null && persistent )
  {
    throw new IllegalStateException( "Must specify path" );
  }
  final File configFile = buildBefore();
  Log log = logProvider.getLog( getClass() );
  Config config = Config.fromFile( configFile ).withServerDefaults().build();
  config.setLogger( log );
  return build( configFile, config, GraphDatabaseDependencies.newDependencies().userLogProvider( logProvider )
      .monitors( new Monitors() ) );
}

代码示例来源:origin: neo4j/neo4j

config.setLogger( logging.getInternalLog( Config.class ) );

代码示例来源:origin: org.neo4j.app/neo4j-server

dependencies = dependencies.userLogProvider( userLogProvider );
log = userLogProvider.getLog( getClass() );
config.setLogger( log );

代码示例来源:origin: org.neo4j/neo4j

config.setLogger( logging.getInternalLog( Config.class ) );

相关文章