我们正在使用maven创建spring-boot应用程序,并将其部署在wildfly10 / jboss7.1上。首先使用log4j2.xml来配置日志记录。现在在wildfly日志记录子系统中创建了一个日志记录配置文件,并将该配置文件添加到MANIFEST.MF文件中,现在.war部署已与日志配置文件链接。日志文件已创建。但是问题是log4j2日志正在日志文件中打印。 如果存在log4j2.xml,则说明正在创建日志,但是我们要更改cli / standalone.xml中的日志级别,因此删除了log4j2.xml。 任何人都可以建议没有log4j2.xml是可能的。我在想一些链接丢失了。
控制器类别:
private static FileLogger logger = FileLogger.create(WelcomeController.class);
@GetMapping("/dashboard")
public ModelAndView welcomeMethod(HttpServletRequest request, HttpServletResponse response,
@ModelAttribute("token") final AccessToken accessToken) {
if(null==accessToken.getJwtToken()) {
logger.trace("A TRACE Message");
logger.debug("A DEBUG Message");
logger.info("An INFO Message");
logger.warn("A WARN Message");
logger.error("An ERROR Message");
return new ModelAndView("redirect:launchApp");
}
jboss-deployment-structure.xml
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<exclude-subsystems>
<subsystem name="logging" />
</exclude-subsystems>
</deployment>
</jboss-deployment-structure>
部署日志配置文件:
[standalone@localhost:9990 /] /deployment=appworkflow.war/subsystem=logging:read-resource(include-runtime=true, recursive=true)
{
"outcome" => "success",
"result" => {"configuration" => {"profile-app-wrk-flow" => {
"error-manager" => undefined,
"filter" => undefined,
"formatter" => {"log4j2-trace-file" => {
"class-name" => "org.jboss.logmanager.formatters.PatternFormatter",
"module" => undefined,
"properties" => {"pattern" => "%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n"}
}},
"handler" => {"log4j2-trace-file" => {
"class-name" => "org.jboss.logmanager.handlers.FileHandler",
"encoding" => undefined,
"error-manager" => undefined,
"filter" => undefined,
"formatter" => "log4j2-trace-file",
"handlers" => [],
"level" => "ALL",
"module" => undefined,
"properties" => {
"append" => "true",
"autoFlush" => "true",
"enabled" => "true",
"fileName" => "D:\\wildfly-11.0.0.Final\\standalone\\log\\log4j2-trace.log"
}
}},
"logger" => {"com.fis.origenate.nextgen" => {
"filter" => undefined,
"handlers" => ["log4j2-trace-file"],
"level" => "TRACE",
"use-parent-handlers" => true
}},
"pojo" => undefined
}}}
}