在 Spring Boot 中禁用自动日志记录配置

2023-11-29

我使用 spring boot 1.2.1.RELEASE 并注意到 spring 在启动时自动更改我的 log4j 配置。

这是我的(春季)依赖项:

<!-- parent includes slf4j and log4j -->
<dependencies>
    <dependency>
        <!-- Import dependency management from Spring Boot -->
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>1.1.2.RELEASE</version>
        <type>pom</type>
        <scope>import</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <version>1.1.2.RELEASE</version>
        <exclusions>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-tomcat</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-logging</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jetty</artifactId>
        <version>1.1.2.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>de.komoot.wanderwalter</groupId>
        <artifactId>wanderwalter-api-models</artifactId>
        <version>1.26-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>de.komoot.wanderwalter</groupId>
        <artifactId>wanderwalter-routing</artifactId>
        <version>1.26-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>com.graphhopper</groupId>
        <artifactId>graphhopper</artifactId>
        <version>0.3-kmt</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <version>${spring.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>${spring.version}</version>
    </dependency>
</dependencies>

<dependencyManagement>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.1.3</version>
        </dependency>
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>1.8</version>
        </dependency>
    </dependencies>
</dependencyManagement>

当我开始我的应用程序时-Dlog4j.configuration=log4j-live.xml -Dlog4j.debug我可以看到,首先使用了我的 log4j 配置,然后 spring 清理它并安装它自己的配置,然后(这是我的猜测)从类路径添加默认的 log4j.xml 。

如何仅使用默认的 log4j 行为或者如何定义 spring 应使用哪些文件进行配置?

Cheers,

Jan


Spring Boot 使用与日志记录系统无关的属性来覆盖默认配置:

如果环境包含属性logging.config那么它将用于初始化日志系统,否则使用默认位置。

So use -Dlogging.config=log4j-live.xml -Dlog4j.debug反而。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在 Spring Boot 中禁用自动日志记录配置 的相关文章

随机推荐

  • NodeJS 中的基本静态文件服务器

    我试图在 Node js 中创建一个静态文件服务器 更多的是作为理解 Node 的练习 而不是作为一个完美的服务器 我很了解 Connect 和 node static 等项目 并完全打算使用这些库来编写更多可用于生产的代码 但我也喜欢了解
  • 可以创建插图吗?

    我知道当你使用par fig c new T 您可以创建插图 但是 我想知道是否可以使用 ggplot2 库来创建 插图 图 更新1 我尝试使用par 用ggplot2 但它不起作用 更新2 我找到了一个可行的解决方案ggplot2 谷歌群
  • 在 iFrame 内的新窗口中打开链接

    我正在寻找创建类似于 Digg Stumbleupon 栏的东西 它固定在新打开的页面的顶部 在我的应用程序中 我显示了一堆指向外部站点的链接 不 当有人单击其中一个时 我希望它们在新选项卡中打开 我的徽标 栏位于页面顶部 我认为这可以使用
  • cookie“安全”标志如何工作?

    我知道 cookie 与secure标志不会通过未加密的连接发送 我想知道这是如何深入运作的 谁负责决定是否发送cookie 客户端仅为加密连接设置此项 这在中定义RFC 6265 Secure 属性将 cookie 的范围限制为 安全 通
  • 如何在symfony2中设置表前缀

    就像问题主题一样 如何在 symfony2 中设置默认表前缀 如果可以为所有实体默认设置 但可以选择覆盖单个实体 那就最好了 在我自己弄清楚这一点之后 我想详细说明如何实现这一目标 Symfony 2 Doctrine 2 1 Note I
  • Fortran 语言中的日期时差

    我的目标是让 fortran 返回作为字符串传入的两个时间之间的差异 与 VBA 的 TimeDiff 非常相似 我已经在 Fortran 中处理日期和时间有一段时间了 但在这种特殊情况下找不到我需要的东西 Fortran 中的第一个问题是
  • 在R中,如何查找位于工作目录之上的任何父目录中的文件?

    当我位于给定的工作目录中时 如何找到位于的文件any上升了几级 我想按文件名搜索该文件 但不知道该文件是否仅位于上一级目录 还是位于上一级目录 因此 我正在寻找一种每次升级一级并搜索文件的方法 找到后 我想获取该文件的绝对完整路径 我正在尝
  • matlab 热图转彩色图像

    我有一个灰度图像 我可以使用以下命令在 matlab 中创建热图 I imagesc I 它以颜色显示强度值 我想使用此热图获取彩色图像 我该怎么做 This is the output of imagesc 据推测 彩色图像 是指 RGB
  • 使用react-data-table-component过滤数据表

    我需要将下面的代码转换为没有钩子的普通类组件 任何人都可以帮助我 这是我指的链接https jbetancur github io react data table component path story filtering exampl
  • C# 如何判断hwnd是否在托盘图标中

    我正在尝试获取当前托盘图标的 hwnd 我所做的是使用以下代码获取系统trat窗口的hWnd DllImport user32 dll SetLastError true static extern IntPtr FindWindowEx
  • 当数组有子数组时 array_intersect 会抛出错误

    我正在尝试使用array intersect比较两个数组的数组 start array id gt 1 name gt Up action gt up start array id gt 3 name gt Down action gt d
  • JBoss Wildfly 与 Jersey Web 服务部署错误 JBAS011859:命名上下文是只读的

    我正在开发一个使用 Jersey Servlet 1 18 1 的 Java Web 服务项目 将我的 EAR 文件部署到 Jboss WildFly 8 1 0 时 我收到以下错误 并且我不确定为什么它会中断 因为同一个 EAR 文件在
  • 如何在 Google App Engine 的 ManyToOne 端按父实体过滤实体

    我使用谷歌应用程序引擎 当我尝试执行如下 JPA 查询时 SELECT p FROM Participant p WHERE p party id partyKey AND p name participantName 我收到以下错误 Ca
  • ng-repeat 动画不起作用

    我的 ng repeat 动画似乎不起作用 这是笨蛋 http plnkr co edit kYtzM9d0rzGmrniybz9c p preview 任何输入 1 您已注册两个模块 And Remove ng app来自 html 标签
  • 按钮悬停颜色更改动画 c#

    我创建了一个 Windows 窗体 它有 3 个按钮 因此 我想通过使用 mouseenter 事件来更改颜色的一键式按钮 工作正常 但我需要通过淡入或淡出的过渡来改变颜色 任何对此问题有答案的人请告诉我下面的代码 我将向您展示我的 mou
  • 通过 aws.push 部署到 Elastic Beanstalk 时保留某些现有文件

    我们在 EC2 服务器上的应用程序目录中有 SOLR 而不是在本地 git 存储库中 当我们将本地存储库推送到 EC2 时 它会删除 Solr 目录 我们已将目录名称放入 gitignore 文件中 但它仍然覆盖 SOLR 目录 我们如何防
  • IE 7 CTRL + 单击打开一个新窗口 - 如何抑制它?

    Is it possible to suppress the default IE 7 functionality when CTRL click on link opens a new window if so how Thanks Th
  • 如何在 SQL Server 2008 中从 IP 地址获取计算机名称?

    我必须从 SQL Server 中的 IP 地址获取计算机名称 我可以做些什么来完成我的任务 DB IPAdd MachineName Query select MachineName from DBTable where IPAdd yo
  • 在安卓中搜索

    我有一个应用程序 我希望在其中添加搜索功能 我正在尝试按照中所述实施developer android但是当我单击模拟器中的搜索时 活动没有启动 问题是什么 SearchActivity java public class SearchAc
  • 在 Spring Boot 中禁用自动日志记录配置

    我使用 spring boot 1 2 1 RELEASE 并注意到 spring 在启动时自动更改我的 log4j 配置 这是我的 春季 依赖项