Springboot,log文件配置时,logging.file.name与logging.file

新版博客编辑界面超级难受,考虑转战其他平台,比如博客园!!!

目录

■前言

■原因

■解决

■·SpringBoot源代码分析

2.1.6中,springboot的源码

2.3.10中,springboot的源码


■前言

·SpringBoot版本升级之后,log文件无法显示。

■原因

2.2.0版本之后,log的key变成了

logging.file.name

之前是

logging.file

■解决

application.properties或者application.yml文件中

logging
 file

logging
 file
  name

■·SpringBoot源代码分析

2.1.6中,springboot的源码

---

package org.springframework.boot.logging;

import java.util.Properties;

import org.springframework.core.env.Environment;
import org.springframework.core.env.PropertyResolver;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;

/**
 * A reference to a log output file. Log output files are specified using
 * {@code logging.file} or {@code logging.path} {@link Environment} properties. If the
 * {@code logging.file} property is not specified {@code "spring.log"} will be written in
 * the {@code logging.path} directory.
 *
 * @author Phillip Webb
 * @since 1.2.1
 * @see #get(PropertyResolver)
 */
public class LogFile {

	/**
	 * The name of the Spring property that contains the name of the log file. Names can
	 * be an exact location or relative to the current directory.
	 */
	public static final String FILE_PROPERTY = "logging.file";

	/**
	 * The name of the Spring property that contains the directory where log files are
	 * written.
	 */
	public static final String PATH_PROPERTY = "logging.path";

	private final String file;

	private final String path;

---

2.3.10中,springboot的源码

---

package org.springframework.boot.logging;

import java.io.File;
import java.util.Properties;

import org.springframework.core.env.Environment;
import org.springframework.core.env.PropertyResolver;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;

/**
 * A reference to a log output file. Log output files are specified using
 * {@code logging.file.name} or {@code logging.file.path} {@link Environment} properties.
 * If the {@code logging.file.name} property is not specified {@code "spring.log"} will be
 * written in the {@code logging.file.path} directory.
 *
 * @author Phillip Webb
 * @author Christian Carriere-Tisseur
 * @since 1.2.1
 * @see #get(PropertyResolver)
 */
public class LogFile {

	/**
	 * The name of the Spring property that contains the name of the log file. Names can
	 * be an exact location or relative to the current directory.
	 * @since 2.2.0
	 */
	public static final String FILE_NAME_PROPERTY = "logging.file.name";

	/**
	 * The name of the Spring property that contains the directory where log files are
	 * written.
	 * @since 2.2.0
	 */
	public static final String FILE_PATH_PROPERTY = "logging.file.path";

	private final String file;

	private final String path;

---

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值