-
Notifications
You must be signed in to change notification settings - Fork 1
io microsphere logging log4j2 layout DelegatingLayout
Type: Class | Module: microsphere-log4j2 | Package: io.microsphere.logging.log4j2.layout | Since: 1.0.0
Source:
microsphere-log4j2/src/main/java/io/microsphere/logging/log4j2/layout/DelegatingLayout.java
Delegating Layout
public class DelegatingLayout<T extends Serializable> implements Layout<T>Author: Mercy
-
Introduced in:
1.0.0 -
Current Project Version:
0.1.14-SNAPSHOT
This component is tested and compatible with the following Java versions:
| Java Version | Status |
|---|---|
| Java 8 | ✅ Compatible |
| Java 11 | ✅ Compatible |
| Java 17 | ✅ Compatible |
| Java 21 | ✅ Compatible |
| Java 25 | ✅ Compatible |
Layout<String> patternLayout = PatternLayout.newBuilder().withPattern("%m").build();
DelegatingLayout<String> layout = new DelegatingLayout<>(patternLayout);DelegatingLayout<String> layout = new DelegatingLayout<>();
layout.setDelegate(PatternLayout.newBuilder().withPattern("%m").build());DelegatingLayout<?> layout = new DelegatingLayout<>(delegate);
byte[] footer = layout.getFooter();DelegatingLayout<?> layout = new DelegatingLayout<>(delegate);
byte[] header = layout.getHeader();DelegatingLayout<?> layout = new DelegatingLayout<>(delegate);
byte[] bytes = layout.toByteArray(logEvent);DelegatingLayout<?> layout = new DelegatingLayout<>(delegate);
Object serialized = layout.toSerializable(logEvent);DelegatingLayout<?> layout = new DelegatingLayout<>(delegate);
String contentType = layout.getContentType();DelegatingLayout<?> layout = new DelegatingLayout<>(delegate);
Map<String, String> format = layout.getContentFormat();DelegatingLayout<?> layout = new DelegatingLayout<>(delegate);
layout.encode(logEvent, destination);DelegatingLayout<String> layout = new DelegatingLayout<>(patternLayout);
Layout<String> delegate = layout.getDelegate();DelegatingLayout<String> layout = new DelegatingLayout<>();
layout.setDelegate(PatternLayout.newBuilder().withPattern("%d %m").build());Add the following dependency to your pom.xml:
<dependency>
<groupId>io.github.microsphere-projects</groupId>
<artifactId>microsphere-log4j2</artifactId>
<version>${microsphere-logging.version}</version>
</dependency>Tip: Use the BOM (
microsphere-logging-dependencies) for consistent version management. See the Getting Started guide.
import io.microsphere.logging.log4j2.layout.DelegatingLayout;| Method | Description |
|---|---|
getFooter |
Creates a new DelegatingLayout wrapping the given delegate Layout. |
getHeader |
{@inheritDoc} |
toByteArray |
{@inheritDoc} |
toSerializable |
{@inheritDoc} |
getContentType |
{@inheritDoc} |
encode |
{@inheritDoc} |
getDelegate |
Returns the underlying delegate Layout. |
setDelegate |
Sets a new delegate Layout. |
public byte[] getFooter()Creates a new DelegatingLayout wrapping the given delegate Layout.
`Layout patternLayout = PatternLayout.newBuilder().withPattern("%m").build();
DelegatingLayout layout = new DelegatingLayout<>(patternLayout);
`
public byte[] getHeader(){@inheritDoc}
`DelegatingLayout layout = new DelegatingLayout<>(delegate); byte[] header = layout.getHeader(); `
public byte[] toByteArray(LogEvent event){@inheritDoc}
`DelegatingLayout layout = new DelegatingLayout<>(delegate); byte[] bytes = layout.toByteArray(logEvent); `
public T toSerializable(LogEvent event){@inheritDoc}
`DelegatingLayout layout = new DelegatingLayout<>(delegate); Object serialized = layout.toSerializable(logEvent); `
public String getContentType(){@inheritDoc}
`DelegatingLayout layout = new DelegatingLayout<>(delegate); String contentType = layout.getContentType(); `
public void encode(LogEvent source, ByteBufferDestination destination){@inheritDoc}
`DelegatingLayout layout = new DelegatingLayout<>(delegate); Map format = layout.getContentFormat(); `
/
public Layout<T> getDelegate()Returns the underlying delegate Layout.
`DelegatingLayout layout = new DelegatingLayout<>(patternLayout); Layout delegate = layout.getDelegate(); `
public void setDelegate(Layout<T> delegate)Sets a new delegate Layout.
`DelegatingLayout layout = new DelegatingLayout<>();
layout.setDelegate(PatternLayout.newBuilder().withPattern("%d %m").build());
`
Layout
This documentation was auto-generated from the source code of microsphere-logging.
java-logging
log4j
log4j2
- DelegatingLayout
- InMemoryAppender
- Log4j2Logger
- Log4j2LoggerFactory
- Log4j2Logging
- Log4j2Utils
- LogEventComparator
- SmartFileAppenderLayout
logback
logging-commons
- DefaultLoggingLevelsResolver
- Logging
- LoggingLevelsResolver
- LoggingMXBeanAdapter
- LoggingMXBeanRegistrar
- LoggingUtils
logging-examples
logging-test