Skip to content

Instantly share code, notes, and snippets.

@tolitius
Created July 7, 2016 13:34
Show Gist options
  • Select an option

  • Save tolitius/71735deeb5c5326adccc5585508a37f5 to your computer and use it in GitHub Desktop.

Select an option

Save tolitius/71735deeb5c5326adccc5585508a37f5 to your computer and use it in GitHub Desktop.
log4j 2.0: changing DEFAULT_PREFIX
// Changing "DEFAULT_PREFIX": https://logging.apache.org/log4j/2.0/log4j-core/apidocs/src-html/org/apache/logging/log4j/core/config/ConfigurationFactory.html#line.108
Field prefix = ConfigurationFactory.class.getField( "DEFAULT_PREFIX" )
prefix.setAccessible( true );
Field mods = Field.class.getDeclaredField( "modifiers" );
mods.setAccessible( true );
mods.setInt( prefix, prefix.getModifiers() & ~Modifier.FINAL );
field.set( null, "logger-config" );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment