我在日志上有点挣扎。我正在使用 Log4j2 的最后一个安全版本。我正在创建此代码作为测试
HashMap<String,Object> msgMap = new HashMap<>();
msgMap.put("someInt", 123);
msgMap.put("note", "Maybe you put a message here");
HashMap<String,Object> anotherMap = new HashMap<>();
anotherMap.put("key1", "value1");
anotherMap.put("key2", "value2");
msgMap.put("map", anotherMap);
logger.info("Test message", anotherMap);
这是我的附加程序
<RollingFile name="appGrayLog"
fileName="${APP_LOG_ROOT}/graylog/AppLog.log"
filePattern="${APP_LOG_ROOT}/graylog/AppLog-%d{yyyy-MM-dd}-%i.log">
<GelfLayout includeThreadContext="true" compressionType="OFF" includeNewLineDelimiter="true">
<KeyValuePair key="component" value="app-myName"/>
<KeyValuePair key="team" value="Team Name"/>
</GelfLayout>
<Policies>
<SizeBasedTriggeringPolicy size="2KB" />
<TimeBasedTriggeringPolicy />
</Policies>
<DefaultRolloverStrategy>
<Delete basePath="${APP_LOG_ROOT}/graylog/">
<IfFileName glob="AppLog-*.log">
<IfLastModified age="3m"/>
</IfFileName>
</Delete>
</DefaultRolloverStrategy>
</RollingFile>
我可以以某种方式访问我从 log4j2.xml 文件中提供给 log.info 方法的这个 msgMap 对象吗?
提前致谢!