### Example URLs for Tjahzi Connection
Source: https://github.com/tkowalcz/tjahzi/blob/master/reload4j-appender/README.md
Demonstrates various valid URL formats for configuring Tjahzi connections, including different protocols, ports, and paths.
```xml
```
```xml
```
```xml
```
```xml
```
--------------------------------
### Advanced Logback Configuration with Loki Appender
Source: https://github.com/tkowalcz/tjahzi/blob/master/logback-appender/README.md
This example demonstrates an advanced configuration for the Loki appender, including custom headers, metadata, and log level labels.
```xml
${loki.host}${loki.port}%-4relative [%thread] %-5level %logger{35} -
%msg%n
X-Org-IdCodewiseenvironmentproduction
log_level
```
--------------------------------
### Setup Standard Monitoring for Log4j2
Source: https://context7.com/tkowalcz/tjahzi/llms.txt
Configures Log4j2's Loki appender to use a standard monitoring module for tracking metrics like dropped puts and sent requests. Access metrics programmatically after setup.
```java
import com.codahale.metrics.MetricRegistry;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.LoggerContext;
import pl.tkowalcz.tjahzi.log4j2.LokiAppender;
import pl.tkowalcz.tjahzi.stats.DropwizardMonitoringModule;
import pl.tkowalcz.tjahzi.stats.StandardMonitoringModule;
public class TjahziMonitoring {
public static void setupStandardMonitoring() {
// Get the Loki appender from Log4j2
LoggerContext context = (LoggerContext) LogManager.getContext(false);
LokiAppender loki = context.getConfiguration().getAppender("Loki");
// Use standard monitoring module
StandardMonitoringModule monitoringModule = new StandardMonitoringModule();
loki.setMonitoringModule(monitoringModule);
// Access metrics programmatically
System.out.println("Dropped puts: " + monitoringModule.getDroppedPuts());
System.out.println("Sent requests: " + monitoringModule.getSentHttpRequests());
System.out.println("Failed requests: " + monitoringModule.getFailedHttpRequests());
}
public static void setupDropwizardMonitoring(MetricRegistry metricRegistry) {
LoggerContext context = (LoggerContext) LogManager.getContext(false);
LokiAppender loki = context.getConfiguration().getAppender("Loki");
// Integrate with Dropwizard metrics
loki.setMonitoringModule(
new DropwizardMonitoringModule(metricRegistry, "appender.loki")
);
// Metrics available:
// - appender.loki.droppedPuts (counter)
// - appender.loki.sentHttpRequests (counter)
// - appender.loki.sentBytes (meter)
// - appender.loki.failedHttpRequests (counter)
// - appender.loki.retriedHttpRequests (counter)
// - appender.loki.httpResponses (counter)
// - appender.loki.responseTimes (timer)
// - appender.loki.agentErrors (counter)
}
}
```
--------------------------------
### Java Example Using MDC with Log4j2
Source: https://context7.com/tkowalcz/tjahzi/llms.txt
Demonstrates how to use Log4j2's ThreadContext to add contextual information (like request and user IDs) to logs, which Tjahzi can then use as labels.
```java
// Using MDC with Log4j2
import org.apache.logging.log4j.ThreadContext;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class MDCExample {
private static final Logger logger = LogManager.getLogger(MDCExample.class);
public void handleRequest(String requestId, String userId) {
// Set MDC values - these will appear as labels in Loki
ThreadContext.put("request_id", requestId);
ThreadContext.put("user_id", userId);
ThreadContext.put("trace_id", generateTraceId());
try {
logger.info("Processing request");
// ... business logic
logger.info("Request completed successfully");
} finally {
ThreadContext.clearAll();
}
}
}
```
--------------------------------
### Tjahzi Logback Appender Configuration with MDC
Source: https://github.com/tkowalcz/tjahzi/blob/master/logback-appender/README.md
Example Logback configuration for TjahziAppender, demonstrating variable substitution for host/port and MDC support for dynamic labels like trace_id and span_id.
```xml
${loki.host}${loki.port}%-4relative [%thread] %-5level %logger{35} -
%msg%n
trace_id
span_id
```
--------------------------------
### Configure LokiAppender with Custom Truststore (Host/Port)
Source: https://github.com/tkowalcz/tjahzi/blob/master/logback-appender/README.md
Example of configuring the LokiAppender with a custom truststore for HTTPS connections using host and port. Specify truststore path, password, and type.
```xml
logs.example.internal8443true/path/to/ca-or-truststore.p12changeitPKCS12
```
--------------------------------
### Configure Loki Host, Port, and Log Endpoint
Source: https://github.com/tkowalcz/tjahzi/blob/master/log4j2-appender/README.md
Set connection details and override the default log endpoint, useful for reverse proxy setups.
```xml
example.com3100/monitoring/loki/api/v1/push
```
--------------------------------
### Set StandardMonitoringModule for Log4j
Source: https://github.com/tkowalcz/tjahzi/wiki/Monitoring
Installs a StandardMonitoringModule to track events in available counters. This is a simple implementation for basic monitoring.
```java
StandardMonitoringModule monitoringModule = new StandardMonitoringModule()
loki.setMonitoringModule(monitoringModule)
```
--------------------------------
### Setup Dropwizard Monitoring for Logback
Source: https://context7.com/tkowalcz/tjahzi/llms.txt
Integrates Logback's Loki appender with Dropwizard metrics, using a helper method to find the appender. Metrics are registered under a specified name prefix.
```java
import ch.qos.logback.classic.LoggerContext;
import com.codahale.metrics.MetricRegistry;
import org.slf4j.LoggerFactory;
import pl.tkowalcz.tjahzi.logback.LokiAppender;
import pl.tkowalcz.tjahzi.stats.DropwizardMonitoringModule;
import java.util.Spliterators;
import java.util.stream.StreamSupport;
public class LogbackMonitoring {
public static LokiAppender getLokiAppender() {
LoggerContext context = (LoggerContext)LoggerFactory.getILoggerFactory();
return (LokiAppender) context.getLoggerList()
.stream()
.flatMap(logger -> StreamSupport.stream(
Spliterators.spliteratorUnknownSize(logger.iteratorForAppenders(), 0),
false
))
.filter(appender -> appender instanceof LokiAppender)
.findAny()
.orElseThrow(() -> new RuntimeException("Loki appender not found"));
}
public static void setupDropwizardMonitoring(MetricRegistry metricRegistry) {
LokiAppender loki = getLokiAppender();
loki.setMonitoringModule(
new DropwizardMonitoringModule(metricRegistry, "logback.loki")
);
}
}
```
--------------------------------
### Configure LokiAppender with Custom Truststore (URL)
Source: https://github.com/tkowalcz/tjahzi/blob/master/logback-appender/README.md
Example of configuring the LokiAppender with a custom truststore for HTTPS connections using a URL. Truststore details can be provided via properties.
```xml
https://logs.example.internal:8443/monitoring/loki/api/v1/push${loki.truststore.path}${loki.truststore.password}${loki.truststore.type}
```
--------------------------------
### Valid Loki Connection URLs
Source: https://github.com/tkowalcz/tjahzi/blob/master/log4j2-appender/README.md
Examples of correctly formatted URLs for Tjahzi to connect to Loki, demonstrating various combinations of protocol, host, port, and path.
```xml
http://example.com
```
```xml
https://example.com:56654
```
```xml
http://example.com/monitoring/loki/api/v1/push
```
```xml
https://example.com:3100/monitoring/foo/bar
```
--------------------------------
### Advanced Log4j2 Configuration with Loki Appender
Source: https://github.com/tkowalcz/tjahzi/blob/master/log4j2-appender/README.md
An advanced configuration example for the root logger with a Loki appender, including buffer size, custom headers, metadata, and log level labels. Ensure the 'packages' attribute is set.
```xml
${sys:loki.host}${sys:loki.port}%X{tid} [%t] %d{MM-dd HH:mm:ss.SSS} %5p %c{1} - %m%n%exception{full}log_level
```
--------------------------------
### Configure LokiAppender with JVM Default Truststore
Source: https://github.com/tkowalcz/tjahzi/blob/master/logback-appender/README.md
Example of configuring the LokiAppender to use the default JVM truststore for HTTPS connections. Ensure is 443 or is true.
```xml
logs.example.com443true
```
--------------------------------
### Setup Dropwizard Monitoring for Log4j2
Source: https://context7.com/tkowalcz/tjahzi/llms.txt
Integrates Log4j2's Loki appender with Dropwizard metrics. Metrics are registered under a specified name prefix.
```java
import com.codahale.metrics.MetricRegistry;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.LoggerContext;
import pl.tkowalcz.tjahzi.log4j2.LokiAppender;
import pl.tkowalcz.tjahzi.stats.DropwizardMonitoringModule;
public class TjahziMonitoring {
public static void setupStandardMonitoring() {
// Get the Loki appender from Log4j2
LoggerContext context = (LoggerContext) LogManager.getContext(false);
LokiAppender loki = context.getConfiguration().getAppender("Loki");
// Use standard monitoring module
StandardMonitoringModule monitoringModule = new StandardMonitoringModule();
loki.setMonitoringModule(monitoringModule);
// Access metrics programmatically
System.out.println("Dropped puts: " + monitoringModule.getDroppedPuts());
System.out.println("Sent requests: " + monitoringModule.getSentHttpRequests());
System.out.println("Failed requests: " + monitoringModule.getFailedHttpRequests());
}
public static void setupDropwizardMonitoring(MetricRegistry metricRegistry) {
LoggerContext context = (LoggerContext) LogManager.getContext(false);
LokiAppender loki = context.getConfiguration().getAppender("Loki");
// Integrate with Dropwizard metrics
loki.setMonitoringModule(
new DropwizardMonitoringModule(metricRegistry, "appender.loki")
);
// Metrics available:
// - appender.loki.droppedPuts (counter)
// - appender.loki.sentHttpRequests (counter)
// - appender.loki.sentBytes (meter)
// - appender.loki.failedHttpRequests (counter)
// - appender.loki.retriedHttpRequests (counter)
// - appender.loki.httpResponses (counter)
// - appender.loki.responseTimes (timer)
// - appender.loki.agentErrors (counter)
}
}
```
--------------------------------
### Reload4j URL Configuration
Source: https://context7.com/tkowalcz/tjahzi/llms.txt
Configure Reload4j to send logs to Loki using a single URL. This example uses `PatternLayout` for formatting.
```xml
```
--------------------------------
### Properties File Configuration for Tjahzi
Source: https://github.com/tkowalcz/tjahzi/blob/master/log4j2-appender/README.md
Example Log4j2 properties file configuration for Tjahzi, including package definition, monitor interval, root logger, Loki appender, layout, and labels. It demonstrates using system properties for host and port.
```properties
#Loads Tjahzi plugin definition
packages="pl.tkowalcz.tjahzi.log4j2"
# Allows this configuration to be modified at runtime. The file will be checked every 30 seconds.
monitorInterval=30
# Standard stuff
rootLogger.level=INFO
rootLogger.appenderRefs=loki
rootLogger.appenderRef.loki.ref=Loki
#Loki configuration
appender.loki.name=Loki
appender.loki.type=Loki
appender.loki.host=${sys:loki.host}
appender.loki.port=${sys:loki.port}
appender.loki.logLevelLabel=log_level
# Layout
appender.loki.layout.type=PatternLayout
appender.loki.layout.pattern=%X{tid} [%t] %d{MM-dd HH:mm:ss.SSS} %5p %c{1} - %m%n%exception{full}
# Labels
appender.loki.labels[0].type=label
appender.loki.labels[0].name=server
appender.loki.labels[0].value=127.0.0.1
appender.loki.labels[1].type=label
appender.loki.labels[1].name=source
appender.loki.labels[1].value=log4j
```
--------------------------------
### RoutingAppender Configuration for Log Routing
Source: https://github.com/tkowalcz/tjahzi/wiki/Dynamic-configuration
Configure a RoutingAppender to dynamically route log events to different subordinate appenders based on a pattern, such as environment variables. This example shows routing to LOKI or CONSOLE appenders.
```xml
```
--------------------------------
### Configure Tjahzi with Log4j2 Properties File
Source: https://context7.com/tkowalcz/tjahzi/llms.txt
Configure the Tjahzi Loki appender using Log4j2's properties file format. This example demonstrates setting up multiple labels, custom batching, and layout patterns. Ensure the Tjahzi plugin definition is loaded.
```properties
# Load Tjahzi plugin definition
packages="pl.tkowalcz.tjahzi.log4j2"
# Configuration monitoring
monitorInterval=30
# Root logger setup
rootLogger.level=INFO
rootLogger.appenderRefs=loki
rootLogger.appenderRef.loki.ref=Loki
# Loki appender configuration
appender.loki.name=Loki
appender.loki.type=Loki
appender.loki.host=${sys:loki.host}
appender.loki.port=${sys:loki.port}
appender.loki.bufferSizeMegabytes=32
appender.loki.batchSize=102400
appender.loki.batchWait=5000
appender.loki.maxRetries=3
appender.loki.logLevelLabel=log_level
# Layout pattern
appender.loki.layout.type=PatternLayout
appender.loki.layout.pattern=%X{tid} [%t] %d{MM-dd HH:mm:ss.SSS} %5p %c{1} - %m%n%exception{full}
# Labels configuration
appender.loki.labels[0].type=label
appender.loki.labels[0].name=server
appender.loki.labels[0].value=127.0.0.1
appender.loki.labels[1].type=label
appender.loki.labels[1].name=source
appender.loki.labels[1].value=log4j
```
--------------------------------
### Initialize and Use Tjahzi Core Logging System
Source: https://context7.com/tkowalcz/tjahzi/llms.txt
Demonstrates building client configuration, initializing the logging system with custom labels and buffer sizes, and logging messages with dynamic labels and metadata. Ensure the NettyHttpClient is properly configured with host, port, and timeouts.
```java
import pl.tkowalcz.tjahzi.*;
import pl.tkowalcz.tjahzi.http.*;
import pl.tkowalcz.tjahzi.stats.StandardMonitoringModule;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
public class TjahziCoreExample {
public static void main(String[] args) throws Exception {
// Build client configuration
ClientConfiguration clientConfig = ClientConfiguration.builder()
.withHost("localhost")
.withPort(3100)
.withConnectionTimeoutMillis(5000)
.withRequestTimeoutMillis(60000)
.withMaxRetries(3)
.build();
// Create monitoring module
StandardMonitoringModule monitoringModule = new StandardMonitoringModule();
// Create HTTP client
NettyHttpClient httpClient = HttpClientFactory.defaultFactory()
.getHttpClient(clientConfig, monitoringModule, "X-Custom-Header", "value");
// Define static labels
Map staticLabels = new HashMap<>();
staticLabels.put("app", "my-application");
staticLabels.put("env", "production");
// Initialize logging system
TjahziInitializer initializer = new TjahziInitializer();
LoggingSystem loggingSystem = initializer.createLoggingSystem(
httpClient,
monitoringModule,
staticLabels,
102400, // batchSizeBytes
5000, // batchWaitMillis
32 * 1024 * 1024, // bufferSizeBytes (32MB)
10, // logShipperWakeupIntervalMillis
10000, // shutdownTimeoutMillis
false // useDaemonThreads
);
// Start the logging system
loggingSystem.start();
// Create logger
TjahziLogger logger = loggingSystem.createLogger();
// Create labels for this log entry
LabelSerializerPair labelPair = LabelSerializers.threadLocal();
LabelSerializer dynamicLabels = labelPair.getLogLabels();
dynamicLabels.appendLabel("request_id", "abc-123");
dynamicLabels.appendLabel("user_id", "user-456");
// Create structured metadata
LabelSerializer metadata = labelPair.getStructuredMetadata();
metadata.appendLabel("trace_id", "trace-789");
// Log a message
String message = "User login successful";
ByteBuffer logLine = ByteBuffer.wrap(message.getBytes(StandardCharsets.UTF_8));
long epochMillis = System.currentTimeMillis();
long nanoOfMillis = System.nanoTime() % 1_000_000;
logger.log(epochMillis, nanoOfMillis, dynamicLabels, metadata, logLine);
// Graceful shutdown
loggingSystem.close(5000, thread -> thread.interrupt());
}
}
```
--------------------------------
### Advanced Configuration with Headers and Labels
Source: https://github.com/tkowalcz/tjahzi/blob/master/reload4j-appender/README.md
Demonstrates advanced configuration options including custom headers, labels, and MDC labels.
```xml
...
X-Org-IdCircus
trace_id
```
--------------------------------
### Label Configuration using Params
Source: https://github.com/tkowalcz/tjahzi/blob/master/reload4j-appender/README.md
Shows how to configure labels using param tags within the label definition.
```xml
```
--------------------------------
### Get Logback Loki Appender
Source: https://github.com/tkowalcz/tjahzi/wiki/Monitoring
Retrieve the Loki appender instance from Logback configuration. This method iterates through loggers and their appenders to find the LokiAppender.
```java
import ch.qos.logback.classic.LoggerContext;
import pl.tkowalcz.tjahzi.logback.LokiAppender;
import java.util.Spliterators;
import java.util.stream.StreamSupport;
...
public static LokiAppender getLokiAppender(LoggerContext context) {
return (LokiAppender) context
.getLoggerList()
.stream()
.flatMap(
logger ->
StreamSupport.stream(
Spliterators.spliteratorUnknownSize(logger.iteratorForAppenders(), 0),
false
)
)
.filter(appender -> appender instanceof LokiAppender)
.findAny()
.orElseThrow(() -> new AssertionError("Expected to find Loki appender"));
}
```
```xml
...
```
--------------------------------
### Minimal Logback Configuration
Source: https://github.com/tkowalcz/tjahzi/blob/master/logback-appender/README.md
Include this minimal appender configuration in your logback.xml file. It sets up the LokiAppender with basic host, port, and an efficient layout pattern.
```xml
${loki.host}${loki.port}%-4relative [%thread] %-5level %logger{35} - %msg%n
```
--------------------------------
### Get Log4j Loki Appender
Source: https://github.com/tkowalcz/tjahzi/wiki/Monitoring
Retrieve the Loki appender instance from Log4j configuration to set up monitoring. Ensure the appender name matches your configuration.
```java
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.LoggerContext;
...
LoggerContext context = (LoggerContext) LogManager.getContext(false);
LokiAppender loki = context.getConfiguration().getAppender("Loki");
```
```xml
...
```
--------------------------------
### Configure Loki Host, Port, and SSL
Source: https://github.com/tkowalcz/tjahzi/blob/master/log4j2-appender/README.md
Configure connection parameters including explicit SSL enablement for Loki.
```xml
example.com3100true
```
--------------------------------
### Configure Log4j2 Labels with MDC and Patterns for Loki
Source: https://context7.com/tkowalcz/tjahzi/llms.txt
Set up static and dynamic labels in Log4j2 configuration for Loki using environment variables, MDC lookups, and Log4j patterns.
```xml
${loki.host}${loki.port}%m%n
```
--------------------------------
### Logback URL Configuration
Source: https://context7.com/tkowalcz/tjahzi/llms.txt
Configure Logback to send logs to Loki using a single URL. The `efficientLayout` is recommended for performance.
```xml
https://loki.example.com:3100/monitoring/loki/api/v1/push%msg%n
```
--------------------------------
### Configure Loki Host and Port
Source: https://github.com/tkowalcz/tjahzi/blob/master/reload4j-appender/README.md
Set the host and port for Tjahzi to connect to Loki. This is the minimum required configuration.
```xml
```
--------------------------------
### Configure Label with Pattern
Source: https://github.com/tkowalcz/tjahzi/blob/master/log4j2-appender/README.md
Define a label using a Log4j2 compatible pattern for dynamic value assignment. This is efficient and allocation-free.
```xml
```
--------------------------------
### Configure Tjahzi Connection Using URL
Source: https://github.com/tkowalcz/tjahzi/blob/master/reload4j-appender/README.md
Configure all connection parameters (host, port, SSL, endpoint) using a single URL. Individual parameter tags cannot be used when a URL is provided.
```xml
```
--------------------------------
### Configure Loki Host and Port
Source: https://github.com/tkowalcz/tjahzi/blob/master/log4j2-appender/README.md
Specify the host and port for Loki connection using XML tags. The port 443 implies SSL usage.
```xml
example.com3100
```
--------------------------------
### Configure Log4j2 RoutingAppender for Dynamic Loki Logging
Source: https://context7.com/tkowalcz/tjahzi/llms.txt
Sets up Log4j2 to dynamically route logs to Loki or the console based on the LOG_TO environment variable. Ensure the 'pl.tkowalcz.tjahzi.log4j2' package is available and Loki host/port are configured via system properties.
```xml
${sys:loki.host}${sys:loki.port}%d{ISO8601} %-5p [%t] %c{1} - %m%n
```
--------------------------------
### Configure Loki Connection via URL
Source: https://github.com/tkowalcz/tjahzi/blob/master/log4j2-appender/README.md
Consolidate all connection parameters (host, port, SSL, endpoint) into a single URL. Other explicit tags are ignored when using URL.
```xml
https://example.com:56654/monitoring/loki/api/v1/push
```
--------------------------------
### Minimal Appender Configuration
Source: https://github.com/tkowalcz/tjahzi/blob/master/reload4j-appender/README.md
This is the basic configuration for the Loki appender, specifying the host and port for Loki.
```xml
```
--------------------------------
### Configure Tjahzi with Custom Truststore (Host/Port)
Source: https://github.com/tkowalcz/tjahzi/blob/master/reload4j-appender/README.md
Configure the LokiAppender with a custom truststore for TLS connections when using host and port. Specify the truststore path, password, and type. The type can be auto-detected by file extension if not explicitly set.
```xml
```
--------------------------------
### Enable EfficientPatternLayout
Source: https://github.com/tkowalcz/tjahzi/blob/master/logback-appender/README.md
To enable Tjahzi's EfficientPatternLayout for reduced allocations, use this configuration within your appender definition.
```xml
...
%-4relative [%thread] %-5level %logger{35} - %msg%n
```
--------------------------------
### Configure Logback Appender for Loki
Source: https://context7.com/tkowalcz/tjahzi/llms.txt
Configure the Logback appender to send logs to Loki. Supports MDC labels, efficient patterns, and structured metadata.
```xml
${loki.host}${loki.port}%-4relative [%thread] %-5level %logger{35} - %msg%nX-Org-IdMyOrganizationtrace_idspan_idlogger_namethread_namelog_levelenvironmentproduction
```
--------------------------------
### Configure Tjahzi with Custom Truststore (URL)
Source: https://github.com/tkowalcz/tjahzi/blob/master/reload4j-appender/README.md
Configure the LokiAppender with a custom truststore for TLS connections when using a URL. Sensitive information like path and password can be provided using system properties or environment variables.
```xml
```
--------------------------------
### Configure Reload4j/Log4j1.x Appender for Loki
Source: https://context7.com/tkowalcz/tjahzi/llms.txt
Configure the Reload4j/Log4j1.x appender for Loki integration using XML. Supports batching, buffering, and MDC labels.
```xml
X-Org-IdCircustrace_id
```
--------------------------------
### Configure SSL for Tjahzi Connection
Source: https://github.com/tkowalcz/tjahzi/blob/master/reload4j-appender/README.md
Manually enable SSL for the Tjahzi connection to Loki. If the port is 443, SSL is used by default.
```xml
```
--------------------------------
### Configure Logback for Grafana Cloud
Source: https://context7.com/tkowalcz/tjahzi/llms.txt
Configure the Logback appender to send logs to Grafana Cloud via HTTPS using basic authentication with an API key.
```xml
logs-prod-us-central1.grafana.net443123456your-grafana-api-key%d{ISO8601} %-5p [%thread] %logger{35} - %msg%n
```
--------------------------------
### Logback TLS/HTTPS Custom Truststore Configuration
Source: https://context7.com/tkowalcz/tjahzi/llms.txt
Configure Logback for HTTPS connections to Loki using a custom truststore. Use system properties or environment variables for sensitive information like passwords.
```xml
https://logs.example.internal:8443/loki/api/v1/push${loki.truststore.path}${loki.truststore.password}JKS%msg%n
```
--------------------------------
### Tjahzi Appender Configuration with Structured Metadata
Source: https://github.com/tkowalcz/tjahzi/blob/master/logback-appender/README.md
Configure structured metadata for log entries sent by TjahziAppender. Supports variable substitution and requires Loki version 2.9 or later.
```xml
...
environmentproductionservice_version${SERVICE_VERSION}
```
--------------------------------
### Configure Log4j2 Buffer Size for Loki
Source: https://context7.com/tkowalcz/tjahzi/llms.txt
Adjust buffer and log line size settings in Log4j2 configuration for Loki. Use smaller values for low-memory environments.
```xml
${loki.host}${loki.port}102400500010105000600003%m%n${loki.host}${loki.port}512002000
```
--------------------------------
### Configure Tjahzi to Rely on JVM Default Truststore for HTTPS
Source: https://github.com/tkowalcz/tjahzi/blob/master/log4j2-appender/README.md
Use this configuration when connecting to Loki endpoints secured with public Certificate Authorities (CAs) like Let's Encrypt. Ensure SSL is enabled by setting the port to 443 or useSSL to true. No explicit truststore configuration is needed.
```xml
logs.example.com443true
```
--------------------------------
### Include No-Dependency Logback Appender
Source: https://github.com/tkowalcz/tjahzi/blob/master/logback-appender/README.md
Add this dependency if you want to use the no-dependency version of the appender. Ensure you are using a compatible version of Netty if you choose the regular appender.
```xml
pl.tkowalcz.tjahzilogback-appender-nodep0.9.39
```
```xml
pl.tkowalcz.tjahzilogback-appender0.9.39
```
--------------------------------
### Add Regular Log4j2 Appender
Source: https://github.com/tkowalcz/tjahzi/blob/master/log4j2-appender/README.md
Include this dependency if your project already uses a compatible version of Netty.
```xml
pl.tkowalcz.tjahzilog4j2-appender0.9.39
```
--------------------------------
### Define Logback Encoder Pattern
Source: https://github.com/tkowalcz/tjahzi/blob/master/logback-appender/README.md
Specify the layout and pattern for log messages using the traditional Logback encoder configuration.
```xml
%-4relative [%thread] %-5level %logger{35} - %msg%n
```
--------------------------------
### Integrate Tjahzi with Dropwizard Metrics
Source: https://github.com/tkowalcz/tjahzi/wiki/Monitoring
Integrates Tjahzi's monitoring module with Dropwizard's MetricRegistry. A prefix is added to all metric names generated by Tjahzi.
```java
loki.setMonitoringModule(
new DropwizardMonitoringModule(
metricRegistry,
"appender.loki"
)
);
```
--------------------------------
### Add reload4j Appender (No-Dependency)
Source: https://github.com/tkowalcz/tjahzi/blob/master/reload4j-appender/README.md
Include this dependency if you want to use the no-dependency version of the appender.
```xml
pl.tkowalcz.tjahzireload4j-appender-nodep0.9.39
```
--------------------------------
### Configure Tjahzi with a Custom Truststore for HTTPS (URL-based)
Source: https://github.com/tkowalcz/tjahzi/blob/master/log4j2-appender/README.md
Use this configuration for URL-based HTTPS connections to Loki endpoints requiring a custom truststore. System properties or environment variables can be used for sensitive information like paths and passwords.
```xml
https://logs.example.internal:8443/monitoring/loki/api/v1/push${sys:loki.truststore.path}${sys:loki.truststore.password}${sys:loki.truststore.type}
```
--------------------------------
### Configure Tjahzi with a Custom Truststore for HTTPS (Host/Port)
Source: https://github.com/tkowalcz/tjahzi/blob/master/log4j2-appender/README.md
Provide a custom truststore for connecting to internal or self-signed HTTPS endpoints. Specify the path, password, and optionally the type of the truststore. Tjahzi can auto-detect the type (PKCS12 or JKS) if not explicitly set.
```xml
logs.example.internal8443true/path/to/ca-or-truststore.p12changeitPKCS12
```
--------------------------------
### Configure Log4j2 Appender for Tjahzi
Source: https://context7.com/tkowalcz/tjahzi/llms.txt
Set up the Tjahzi Loki appender in Log4j2's XML configuration. This includes defining the Loki host, port, filters, layout, headers, labels, and metadata. Ensure the 'pl.tkowalcz.tjahzi.log4j2' package is included.
```xml
${sys:loki.host}${sys:loki.port}%X{tid} [%t] %d{MM-dd HH:mm:ss.SSS} %5p %c{1} - %m%n%exception{full}log_level
```
--------------------------------
### Configure Tjahzi to Use JVM Default Truststore for TLS
Source: https://github.com/tkowalcz/tjahzi/blob/master/reload4j-appender/README.md
Configure the LokiAppender to use the default JVM truststore for validating server certificates over HTTPS. Ensure SSL is enabled by setting the port to 443 or useSSL to true. No explicit truststore parameters are needed.
```xml
```