日本搞逼视频_黄色一级片免费在线观看_色99久久_性明星video另类hd_欧美77_综合在线视频

國(guó)內(nèi)最全I(xiàn)T社區(qū)平臺(tái) 聯(lián)系我們 | 收藏本站
阿里云優(yōu)惠2
您當(dāng)前位置:首頁(yè) > php框架 > 框架設(shè)計(jì) > Spring Boot 2.0.0參考手冊(cè)_中英文對(duì)照_Part IV_26

Spring Boot 2.0.0參考手冊(cè)_中英文對(duì)照_Part IV_26

來(lái)源:程序員人生   發(fā)布時(shí)間:2017-03-04 08:52:40 閱讀次數(shù):5888次

文章作者:Tyan
博客:noahsnail.com  |  CSDN  |  簡(jiǎn)書(shū)

26. Logging

Spring Boot uses Commons Logging for all internal logging, but leaves the underlying log implementation open. Default configurations are provided for Java Util Logging, Log4J2 and Logback. In each case loggers are pre-configured to use console output with optional file output also available.

Spring Boot所有的內(nèi)部日志都采取Commons Logging,但開(kāi)放了底層的日志實(shí)現(xiàn)。提供了對(duì)Java Util Logging,Log4J2和Logback的默許實(shí)現(xiàn)。在每一個(gè)logger中都預(yù)先配置使用控制臺(tái)作為輸出,同時(shí)也可用可選的文件輸出。

By default, If you use the ‘Starters’, Logback will be used for logging. Appropriate Logback routing is also included to ensure that dependent libraries that use Java Util Logging, Commons Logging, Log4J or SLF4J will all work correctly.

默許情況下,如果使用Starters,Logback將作為日志。也要包括恰當(dāng)?shù)腖ogback規(guī)則來(lái)保證依賴庫(kù)使用Java Util Logging,Commons Logging,Log4J或SLF4J都能正確工作。

There are a lot of logging frameworks available for Java. Don’t worry if the above list seems confusing. Generally you won’t need to change your logging dependencies and the Spring Boot defaults will work just fine.

 

在Java中有許多日志框架可用。沒(méi)必要擔(dān)心上面的列表看起來(lái)有點(diǎn)混亂。通常情況下你不需要改變你的日志依賴,Spring Boot默許情況下能很好的工作。

26.1 Log format

The default log output from Spring Boot looks like this:

Spring Boot默許的日志輸出看起來(lái)以下:

2014-03-05 10:57:51.112  INFO 45469 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/7.0.52
2014-03-05 10:57:51.253  INFO 45469 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2014-03-05 10:57:51.253  INFO 45469 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1358 ms
2014-03-05 10:57:51.698  INFO 45469 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean        : Mapping servlet: 'dispatcherServlet' to [/]
2014-03-05 10:57:51.702  INFO 45469 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]

The following items are output:

  • Date and Time?—?Millisecond precision and easily sortable.

  • Log Level?—?ERROR, WARN, INFO, DEBUG or TRACE.

  • Process ID.

  • A --- separator to distinguish the start of actual log messages.

  • Thread name?—?Enclosed in square brackets (may be truncated for console output).

  • Logger name?—?This is usually the source class name (often abbreviated).

  • The log message.

下面的是輸出項(xiàng):

  • Date and Time?—?精確到毫秒且容易排序。

  • Log級(jí)別?—?ERROR,WARN,INFO,DEBUG或TRACE。

  • 進(jìn)程ID。

  • ---分隔符來(lái)辨別真實(shí)的日志信息的開(kāi)始。

  • 線程名稱?—?用方括號(hào)包裹(在控制臺(tái)輸出中常常是縮減的)。

  • Logger名稱?—?源類名(常常是簡(jiǎn)寫(xiě))。

  • 日志信息。

Logback does not have a FATAL level (it is mapped to ERROR)

 

Logback沒(méi)有FATAL級(jí)別(它映照到ERROR)。

26.2 Console output

The default log configuration will echo messages to the console as they are written. By default ERROR, WARN and INFO level messages are logged. You can also enable a “debug” mode by starting your application with a --debug flag.

默許的日志配置會(huì)將信息輸出到控制臺(tái)。默許情況下會(huì)輸出ERRORWARNINFO級(jí)別的信息。你也能夠通過(guò)--debug來(lái)啟動(dòng)你的利用,從而啟用“debug”模式。

$ java -jar myapp.jar --debug

you can also specify debug=true in your application.properties.

 

你也能夠在application.properties指定debug=true。

When the debug mode is enabled, a selection of core loggers (embedded container, Hibernate and Spring Boot) are configured to output more information. Enabling the debug mode does not configure your application to log all messages with DEBUG level.

當(dāng)啟用調(diào)試模式時(shí),配置選擇的核心logger(嵌入式容器,Hibernate和Spring Boot)來(lái)輸出更多的信息。啟動(dòng)調(diào)試模式不會(huì)將你的利用配置成輸出所有DEBUG級(jí)別的信息。

Alternatively, you can enable a “trace” mode by starting your application with a --trace flag (or trace=true in your application.properties). This will enable trace logging for a selection of core loggers (embedded container, Hibernate schema generation and the whole Spring portfolio).

或,你可以用--trace標(biāo)記(或在application.properties中添加trace=true)啟動(dòng)你的利用,從而啟用“trace”模式。這將在選擇的核心logger中(嵌入式容器,Hibernate模式生成和全部Spring文件夾)啟用trace日志。

26.2.1 Color-coded output

If your terminal supports ANSI, color output will be used to aid readability. You can set spring.output.ansi.enabled to a supported value to override the auto detection.

如果你的終端支持ANSI,色彩輸出可以用來(lái)輔助瀏覽。你可以為spring.output.ansi.enabled設(shè)置1個(gè)支持值來(lái)覆蓋自動(dòng)檢測(cè)。

Color coding is configured using the %clr conversion word. In its simplest form the converter will color the output according to the log level, for example:

色彩編碼用%clr轉(zhuǎn)換詞來(lái)配置。最簡(jiǎn)單的情勢(shì)是根據(jù)日志級(jí)別進(jìn)行色彩輸出,例如:

%clr(%5p)

The mapping of log level to a color is as follows:

日志級(jí)別與色彩的映照以下:

Level Color
FATAL Red
ERROR Red
WARN Yellow
INFO Green
DEBUG Green
TRACE Green

Alternatively, you can specify the color or style that should be used by providing it as an option to the conversion. For example, to make the text yellow:

或,你可以通過(guò)在轉(zhuǎn)換器中提供選項(xiàng)來(lái)指定應(yīng)當(dāng)試用的色彩或風(fēng)格。例如,為了使文本顯示黃色:

%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){yellow}

The following colors and styles are supported:

支持下面的色彩和風(fēng)格:

  • blue
  • cyan
  • faint
  • green
  • magenta
  • red
  • yellow

26.3 File output

By default, Spring Boot will only log to the console and will not write log files. If you want to write log files in addition to the console output you need to set a logging.file or logging.path property (for example in your application.properties).

默許情況下,Spring Boot只能輸出日志到控制臺(tái),不會(huì)寫(xiě)入日志文件。如果你想除控制臺(tái)以外還想寫(xiě)日志文件,你需要設(shè)置logging.filelogging.path屬性(例如,在你的application.properties)。

The following table shows how the logging.* properties can be used together:

下表顯示了logging.*屬性怎樣在1起使用:

Table 26.1. Logging properties

logging.file logging.path Example Description
(none (none) Console only logging.
Specific file (none) my.log Writes to the specified log file. Names can be an exact location or relative to the current directory.
(none) Specific directory /var/log Writes spring.log to the specified directory. Names can be an exact location or relative to the current directory.

表 26.1. Logging屬性

logging.file logging.path Example Description
(none (none) 只輸出到控制臺(tái)
指定文件 (none) my.log 寫(xiě)入指定的日志文件。名字可以是1個(gè)絕對(duì)位置或相對(duì)當(dāng)前目錄。
(none) Specific directory /var/log 寫(xiě)spring.log到1個(gè)指定的目錄。名字可以是1個(gè)絕對(duì)位置或相對(duì)當(dāng)前目錄。

Log files will rotate when they reach 10 MB and as with console output, ERROR, WARN and INFO level messages are logged by default.

當(dāng)日志文件到達(dá)10M光陰志文件將循環(huán),至于控制臺(tái)輸出,默許情況下只輸出ERROR,WARNINFO級(jí)別的信息。

The logging system is initialized early in the application lifecycle and as such logging properties will not be found in property files loaded via @PropertySource annotations.

 

日志系統(tǒng)在利用程序的生命周期初期進(jìn)行初始化,一樣地,通過(guò)@PropertySource注解加載的屬性文件中將不會(huì)發(fā)現(xiàn)日志屬性。

 

Logging properties are independent of the actual logging infrastructure. As a result, specific configuration keys (such as logback.configurationFile for Logback) are not managed by spring Boot.

 

日志屬性獨(dú)立于真實(shí)的日志基礎(chǔ)架構(gòu)以外。因此,Spring Boot不管理特定的配置主鍵(例如Logback的logback.configurationFile)。

26.4 Log Levels

All the supported logging systems can have the logger levels set in the Spring Environment (so for example in application.properties) using ‘logging.level.*=LEVEL’ where ‘LEVEL’ is one of TRACE, DEBUG, INFO, WARN, ERROR, FATAL, OFF. The root logger can be configured using logging.level.root. Example application.properties:

Spring支持的所有日志系統(tǒng)都可以在Spring的Environment中設(shè)置日志級(jí)別(例如在application.properties設(shè)置),使用logging.level.*=LEVEL進(jìn)行設(shè)置,LEVEL是TRACE,DEBUG,INFO,WARN,ERROR,F(xiàn)ATAL,OFF中的1個(gè)。root日志器可以用logging.level.root來(lái)配置。例如在application.properties中:

logging.level.root=WARN
logging.level.org.springframework.web=DEBUG
logging.level.org.hibernate=ERROR

By default Spring Boot remaps Thymeleaf INFO messages so that they are logged at DEBUG level. This helps to reduce noise in the standard log output. See LevelRemappingAppender for details of how you can apply remapping in your own configuration.

 

默許情況下Spring Boot重新映照Thymeleaf的INFO信息,為了它們能在DEBUG級(jí)別進(jìn)行輸出。這能幫助減少標(biāo)準(zhǔn)日志輸出中的噪聲。關(guān)于怎樣在你自己的配置中使用重新映照的更多細(xì)節(jié)請(qǐng)看LevelRemappingAppender

26.5 Custom log configuration

The various logging systems can be activated by including the appropriate libraries on the classpath, and further customized by providing a suitable configuration file in the root of the classpath, or in a location specified by the Spring Environment property logging.config.

在類路徑中通過(guò)包括恰當(dāng)?shù)膸?kù)可以激活各種日志系統(tǒng),在類路徑的根目錄中提供1個(gè)適合的配置文件可以對(duì)日志系統(tǒng)進(jìn)行更進(jìn)1步的定制,或?qū)⑴渲梦募旁赟pring Environmentlogging.config屬性中指定的位置。

You can force Spring Boot to use a particular logging system using the org.springframework.boot.logging.LoggingSystem system property. The value should be the fully-qualified class name of a LoggingSystem implementation. You can also disable Spring Boot’s logging configuration entirely by using a value of none.

你可使用系統(tǒng)屬性org.springframework.boot.logging.LoggingSystem來(lái)強(qiáng)迫Spring Boot使用1個(gè)特定的日志系統(tǒng)。它的值應(yīng)當(dāng)是全限定類名的LoggingSystem實(shí)現(xiàn)。你也能夠通過(guò)使用值none來(lái)完全禁用Spring Boot的日志配置。

Since logging is initialized before the ApplicationContext is created, it isn’t possible to control logging from @PropertySources in Spring @Configuration files. System properties and the conventional Spring Boot external configuration files work just fine.

 

由于日志是在ApplicationContext創(chuàng)建之前初始化,因此不可能從Spring @Configuration文件中的@PropertySources來(lái)控制日志。系統(tǒng)屬性和傳統(tǒng)的Spring Boot外部配置文件可以工作的很好。

Depending on your logging system, the following files will be loaded:

根據(jù)你的日志系統(tǒng),將會(huì)加載下面的文件:

Logging System Customization
Logback logback-spring.xml, logback-spring.groovy, logback.xml or logback.groovy
Log4j2 log4j2-spring.xml or log4j2.xml
JDK (Java Util Logging) logging.properties

When possible we recommend that you use the -spring variants for your logging configuration (for example logback-spring.xml rather than logback.xml). If you use standard configuration locations, Spring cannot completely control log initialization.

 

我們建議你盡量的使用-spring變種來(lái)進(jìn)行日志配置(例如,logback-spring.xml而不是logback.xml)。如果你在使用標(biāo)準(zhǔn)的配置路徑,Spring不能完全控制日志的初始化。

 

There are known classloading issues with Java Util Logging that cause problems when running from an ‘executable jar’. We recommend that you avoid it if at all possible.

 

在Java Java Util Logging中存在類加載問(wèn)題,當(dāng)從executable jar運(yùn)行時(shí)會(huì)引發(fā)問(wèn)題。我們建議你盡量的避免它。

To help with the customization some other properties are transferred from the Spring Environment to System properties:

為了幫助定制1些其它屬性,從Spring Environment中轉(zhuǎn)移到系統(tǒng)屬性中:

Spring Environment System Property Comments
logging.exception-conversion-word LOG_EXCEPTION_CONVERSION_WORD The conversion word that’s used when logging exceptions.
logging.file LOG_FILE Used in default log configuration if defined.
logging.path LOG_PATH Used in default log configuration if defined.
logging.pattern.console CONSOLE_LOG_PATTERN The log pattern to use on the console (stdout). (Only supported with the default logback setup.)
logging.pattern.file FILE_LOG_PATTERN The log pattern to use in a file (if LOG_FILE enabled). (Only supported with the default logback setup.)
logging.pattern.level LOG_LEVEL_PATTERN The format to use to render the log level (default %5p). (Only supported with the default logback setup.)
PID PID The current process ID (discovered if possible and when not already defined as an OS environment variable).
Spring Environment System Property Comments
logging.exception-conversion-word LOG_EXCEPTION_CONVERSION_WORD 當(dāng)日志出現(xiàn)異常時(shí)會(huì)用到這個(gè)轉(zhuǎn)換詞。
logging.file LOG_FILE 如果定義了,會(huì)在默許的日志配置中使用。
logging.path LOG_PATH 如果定義了,會(huì)在默許的日志配置中使用。
logging.pattern.console CONSOLE_LOG_PATTERN 用在控制臺(tái)中的日志模式(stdout)。(只支持默許的Logback設(shè)置。)
logging.pattern.file FILE_LOG_PATTERN 用在文件中的日志模式 (如果啟用LOG_FILE)。(只支持默許的Logback設(shè)置。)
logging.pattern.level LOG_LEVEL_PATTERN 這類模式用來(lái)實(shí)行日志級(jí)別(默許%5p)。 (只支持默許的Logback設(shè)置。)
PID PID 當(dāng)前的進(jìn)程ID

All the logging systems supported can consult System properties when parsing their configuration files. See the default configurations in spring-boot.jar for examples.

當(dāng)轉(zhuǎn)換配置文件時(shí),所有的日志系統(tǒng)都支持查詢系統(tǒng)屬性。例如spring-boot.jar的默許配置。

If you want to use a placeholder in a logging property, you should use Spring Boot’s syntax and not the syntax of the underlying framework. Notably, if you’re using Logback, you should use : as the delimiter between a property name and its default value and not :-.

 

如果你在日志屬性中想使用占位符,你應(yīng)當(dāng)試用Spring Boot的語(yǔ)法而不是底層框架的語(yǔ)法。特別是,如果你在使用Logback,你應(yīng)當(dāng)使用:作為屬性名和默許值之間的分隔符,而不是:-。

 

You can add MDC and other ad-hoc content to log lines by overriding only the LOG_LEVEL_PATTERN (or logging.pattern.level with Logback). For example, if you use logging.pattern.level=user:%X{user} %5p then the default log format will contain an MDC entry for “user” if it exists, e.g.

2015-09⑶0 12:30:04.031 user:juergen INFO 22174 --- [  nio⑻080-exec-0] demo.Controller
Handling authenticated request

 

你可以通太重寫(xiě)LOG_LEVEL_PATTERN(或Logback中的logging.pattern.level)來(lái)添加MDC和其它的專門(mén)內(nèi)容來(lái)日志行中。例如,你可使用logging.pattern.level=user:%X{user} %5p,默許的日志情勢(shì)將包括MDC輸入,如果它存在的話,例如:

2015-09⑶0 12:30:04.031 user:juergen INFO 22174 --- [  nio⑻080-exec-0] demo.Controller
Handling authenticated request

26.6 Logback extensions

Spring Boot includes a number of extensions to Logback which can help with advanced configuration. You can use these extensions in your logback-spring.xml configuration file.

Spring Boot包括許多Logback的擴(kuò)大,這有助于進(jìn)行更高級(jí)的配置。你可以在你的logback-spring.xml配置文件中使用這些擴(kuò)大。

You cannot use extensions in the standard logback.xml configuration file since it’s loaded too early. You need to either use logback-spring.xml or define a logging.config property.

 

你不能在標(biāo)準(zhǔn)的logback.xml配置文件中使用擴(kuò)大,由于它加載的太早了。你需要使用logback-spring.xml或定義logging.config屬性。

26.6.1 Profile-specific configuration

The <springProfile> tag allows you to optionally include or exclude sections of configuration based on the active Spring profiles. Profile sections are supported anywhere within the <configuration> element. Use the name attribute to specify which profile accepts the configuration. Multiple profiles can be specified using a comma-separated list.

<springProfile>標(biāo)簽允許你自由的包括或排除基于激活的Spring profiles的配置的1部份。在<configuration>元素的任何地方都支持Profile部份。使用name屬性來(lái)指定哪個(gè)profile接受配置。多個(gè)profiles可以用1個(gè)逗號(hào)分隔的列表來(lái)指定。

<springProfile name="staging">
    <!-- configuration to be enabled when the "staging" profile is active -->
</springProfile>

<springProfile name="dev, staging">
    <!-- configuration to be enabled when the "dev" or "staging" profiles are active -->
</springProfile>

<springProfile name="!production">
    <!-- configuration to be enabled when the "production" profile is not active -->
</springProfile>

26.6.2 Environment properties

The <springProperty> tag allows you to surface properties from the Spring Environment for use within Logback. This can be useful if you want to access values from your application.properties file in your logback configuration. The tag works in a similar way to Logback’s standard <property> tag, but rather than specifying a direct value you specify the source of the property (from the Environment). You can use the scope attribute if you need to store the property somewhere other than in local scope. If you need a fallback value in case the property is not set in the Environment, you can use the defaultValue attribute.

<springProperty>標(biāo)簽允許你在Logback使用從Spring Environment取得的屬性。如果你想在你的Logback配置中訪問(wèn)application.properties文件中的屬性,這是非常有用的。這個(gè)標(biāo)簽與Logback的標(biāo)準(zhǔn)<property>標(biāo)簽的作用方式類似,但不是為你指定的source屬性(從Environment中)指定1個(gè)直接的value。如果你需要在某個(gè)地方而不是在local作用域中存儲(chǔ)屬性,你可使用scope屬性。如果你需要1個(gè)備用值以防屬性沒(méi)有在Environment中設(shè)置,你可使用defaultValue屬性。

<springProperty scope="context" name="fluentHost" source="myapp.fluentd.host"
        defaultValue="localhost"/>
<appender name="FLUENT" class="ch.qos.logback.more.appenders.DataFluentAppender">
    <remoteHost>${fluentHost}</remoteHost>
    ...
</appender>

The RelaxedPropertyResolver is used to access Environment properties. If specify the source in dashed notation (my-property-name) all the relaxed variations will be tried (myPropertyName, MY_PROPERTY_NAME etc).

 

RelaxedPropertyResolver是用來(lái)訪問(wèn)Environment屬性。如果在破折號(hào)符號(hào)中指定了source,則會(huì)嘗試所有的不嚴(yán)格的變種(myPropertyName,MY_PROPERTY_NAME等)。

生活不易,碼農(nóng)辛苦
如果您覺(jué)得本網(wǎng)站對(duì)您的學(xué)習(xí)有所幫助,可以手機(jī)掃描二維碼進(jìn)行捐贈(zèng)
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關(guān)閉
程序員人生
主站蜘蛛池模板: 国产成人在线不卡 | 黄网视频在线观看 | 久久精品人人爽 | 国产一区二区三区色淫影院 | 精品国产乱码久久久久久丨区2区 | 五月婷婷丁香网 | 久久久精品免费观看 | 欧美日韩中文字幕 | 国产a视频 | 欧美亚洲一二三 | 深夜爱爱视频 | 午夜男人网 | 日韩一二| 日韩美女一区二区三区 | xxxx中国一级片 | 精品国产视频在线观看 | 精品欧美一区二区三区在线观看 | 国产精品久久久久久久久久久免费看 | 最新版天堂中文在线官网 | 加勒比在线免费视频 | 国产日韩在线视频 | 日本久久久网站 | 亚洲欧美一区二区三区国产精品 | 狼人综合网 | 国产精品美女久久久久aⅴ国产馆 | 一级片免费视频 | 国产成人亚洲综合 | 国产精品久久亚洲 | 国产一区二区免费看 | 国产精品久久久久aaaa九色 | 偷拍自拍在线观看 | 久久精品2019中文字幕 | 欧美成人福利 | 中文字幕av片 | 2015成人永久免费视频 | 亚洲国内精品 | 一区二区国产在线 | 国产剧情一区二区 | 亚洲一区二区三区中文字幕 | 欧美色图在线观看 | 国产精品亚洲一区二区三区在线观看 |