java - 从命令行启动时,Spring Batch 不产生日志输出
问题描述
如标题所述,当我从命令行启动 Spring Batch 作业时,不会生成任何日志。
背景资料:
- 我正在使用的日志框架:log4j2
- 从 Eclipse 中启动时,日志记录通常
Logger log = LogManager.getLogger(Application.class)
可以正常工作(手动日志记录是通过 完成的)。但是,有时它也随机不起作用。当我运行 maven“安装”时,似乎会出现这个问题,如果我执行简单的 maven“清洁”,它就会消失 - 我没有使用所有的 Spring Boot(开销太大);在下面查看我的依赖项
- 我用来启动我的作业的命令:
"C:/path/to/java.exe" -cp "target/dependency-jars/*;target/my.jar" org.springframework.batch.core.launch.support.CommandLineJobRunner my.package.my.Config jobName parameters=values
我的pom.xml
:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-batch</artifactId>
<!-- exclude the default, which is logback, not log4j2 -->
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
<version>2.0.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
<version>2.0.2.RELEASE</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<resources>
<resource>
<directory>resources</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>
${project.build.directory}/dependency-jars/
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
解决方案
推荐阅读
- r - 您如何在 R 中的分布函数中找到未知数?
- python - Python:如何计算数据框中所有点之间的距离?
- r - xts 对象 - 添加缺失的日期
- python - Pandas 使用 Dataframe 对象的变量
- r - 在 Python 中生成所有可能的对并计算频率
- c++ - CreateThread 和 CreateRemoteThread 的 lpParameter 有什么区别?
- three.js - instancedMesh:顶点会失去精度
- java - org.springframework.dao.OptimisticLockingFailureException 与休眠升级
- mongodb - MongoDB 日志没有使用 Docker-Compose 和 Windows 10 Home 持久化
- c# - 期望列表的模拟方法