Skip to content

Instantly share code, notes, and snippets.

@TharindaW
Created June 20, 2021 13:47
Show Gist options
  • Save TharindaW/da7dbf2e414ebf6bc652d8c2a6de0796 to your computer and use it in GitHub Desktop.
Save TharindaW/da7dbf2e414ebf6bc652d8c2a6de0796 to your computer and use it in GitHub Desktop.
@Plugin(name = "NewCustLayout", category = Node.CATEGORY, elementType = Layout.ELEMENT_TYPE, printObject = true)
public class NewCustLayout extends AbstractStringLayout
{
protected NewCustLayout( Charset charset )
{
super( charset );
}
@Override public String toSerializable( LogEvent event )
{
return null;
}
}
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Configuration packages="logging.log4j.custom.plugins" name="SOME NAME">
<Appenders>
<Console name="CONSOLE" target="SYSTEM_OUT">
<PatternLayout pattern="%d{MM-dd-yyyy HH:mm:ss,SSS} [%t] %custLayConv %msg%n"/>
</Console>
<RollingRandomAccessFile name="example" fileName="${sys:tbx.log.path}example.log" filePattern="${sys:tbx.log.path}example.log.%i" append="true" immediateFlush="true" bufferSize="262144">
<NewCustLayout pattern="%d{MM-dd-yyyy HH:mm:ss,SSS} - %msg%n"/>
<Policies>
<SizeBasedTriggeringPolicy size="100MB"/>
</Policies>
<DefaultRolloverStrategy fileIndex="max" min="1" max="100" compressionLevel="3"/>
</RollingRandomAccessFile>
</Appenders>
<Loggers>
<logger name="logger" level="INFO" additivity="false">
<AppenderRef ref="example" level="INFO"/>
</logger>
<Root level="INFO">
<AppenderRef ref="CONSOLE" level="INFO"/>
</Root>
</Loggers>
</Configuration>
@Plugin(name = "NewLayoutConverter", category = "Converter")
@ConverterKeys({"custLayConv"})
public class NewLayoutConverter extends LogEventPatternConverter
{
/**
* Constructs an instance of LoggingEventPatternConverter.
*
* @param name name of converter.
* @param style CSS style for output.
*/
protected NewLayoutConverter( String name, String style )
{
super( name, style );
}
@Override public void format( LogEvent event, StringBuilder toAppendTo )
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment