Skip to content

Commit e2203a5

Browse files
committed
Add prometheus metrics for log4j log entries
Enabled default log4j metrics collector. The number of log4j log entries will be counted. This enable the following measurable metrics (captured after clean startup gitblit): # HELP log4j_appender_total Log4j log statements at various log levels # TYPE log4j_appender_total counter log4j_appender_total{level="debug",} 0.0 log4j_appender_total{level="warn",} 1.0 log4j_appender_total{level="trace",} 0.0 log4j_appender_total{level="error",} 0.0 log4j_appender_total{level="fatal",} 0.0 log4j_appender_total{level="info",} 82.0
1 parent 103e4e4 commit e2203a5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main/java/log4j.properties

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# FATAL, ERROR, WARN, INFO, DEBUG
1818
#
1919
#------------------------------------------------------------------------------
20-
log4j.rootCategory=INFO, S
20+
log4j.rootCategory=INFO, S, METRICS
2121

2222
#log4j.rootLogger=INFO
2323
#log4j.logger.org=INFO
@@ -67,3 +67,6 @@ log4j.appender.H.File = logs/gitblit.html
6767
log4j.appender.H.MaxFileSize = 100KB
6868
log4j.appender.H.Append = false
6969
log4j.appender.H.layout = org.apache.log4j.HTMLLayout
70+
71+
log4j.appender.METRICS = io.prometheus.client.log4j.InstrumentedAppender
72+
log4j.appender.METRICS.Append = false

0 commit comments

Comments
 (0)