ApacheDS 2.0__Basic User Guide 1.4.4 - Configure logging (基础用户指导手册)

标签: LDAP ApacheDS 2.0 Basic User Guide
357人阅读 评论(0) 收藏 举报

对 ApacheDS 2.0的Basic User Guide 进行翻译学习。http://directory.apache.org/apacheds/basic-ug/1.4.4-configure-logging.html

1.4.4 - Configure logging


In order to detect and analyze problems, adjusting the log level of a server can be a valuable tool. This section describes how to configure logging within a standalone ApacheDS.

为了侦测和分析问题,对ldap server的log级别的调整也是有价值的。该段描述了如何在一个独立的Apache DS里去配置日志相关。

ApacheDS and logging

ApacheDS 2.0 uses SLF4J as its logging solution. This is a simple facade for various logging APIs. The default for ApacheDS 2.0 islog4j.

ApacheDS 2.0 使用 SLFJ 作为他的日志解决方案。 这是一个对各种各样的日志 API 的简单外观包装。Apache DS2.0 默认使用Log4J.

Default behavior after installation


By default, ApacheDS writes log files in the directory /var/log/. Besides stdout, aRollingFileAppender is used to collect warnings and errors. It backups the log files when they reach a certain size.

作为默认情况,DS 会在把日志文件记录在/var/log/目录 (/ 代表 DS的安装目录)。除了控制台stdout , 一个RollingFileAppender (周期性质生成一个一个文件的API)也被使用去收集 警告和错误。当日志文件到达了指定的文件大小size, 它将备份那些日志文件。

log4j.rootCategory=WARN, stdout, R



# Keep some backup files

log4j.appender.R.layout.ConversionPattern=[%d{HH:mm:ss}] %p [%c] - %m%n

log4j.appender.stdout.layout.ConversionPattern=[%d{HH:mm:ss}] %p [%c] - %m%n

# with these we'll not get inundated when switching to DEBUG
In this file "R" is configured like this:

Property name Value in file above Meaning
File apacheds-rolling.log Path to the output log file, in our case relative to var/log
MaxFileSize 1024KB Maximum size that the output file is allowed to reach before being rolled over to backup files
MaxBackupIndex 5 Number of backup files kept
layout.ConversionPattern [%d Format string for logging events

Adjusting logging to your needs

根据自己的需求去调整日志记录吧 这儿就是个参考模版

Log file location (where the log files are placed)

By default the log files are placed at /var/log/, but that can be changed.

日志文件位置。默认情况下 文件存在/var/log/, 但也是可以被修改自定义的。


On this systems the location of the log files is configured via an entry in /bin/server.init. Look for the following lines and change it to your preferences:

在上面的三种系统中,日志文件的存放位置可以通过配置 /bin/server.int来修改。参考下面的配置, 可以改成适合你自己的哦。

$DAEMON_HOME/apacheds \
-outfile $SERVER_HOME/var/log/apacheds-stdout.log \
-errfile $SERVER_HOME/var/log/apacheds-stderr.log \


On Windows you can use the configuration wizard for the service as shown in the screenshot above. To adjust the log path you have to adjust the values ofRedirect Stdout and Redirect Stderror

对于win系统来说 你可以使用配置向导 (在上面的截图中)。去调整日志的路径时候,你必须去调整 redirect stdout 和 redirect stderror.

Log level (how detailed the logs are)

The following log levels from log4j are used for messages within ApacheDS:

在apache ds中log4j的日志级别 (例如选择了debug级别 就会把其下面所有级别日志都记录,选择errror级别 也会记录fatal)

Level Description from log4j documentation
DEBUG Designates fine-grained informational events that are most useful to debug an application
INFO Designates informational messages that highlight the progress of the application at coarse-grained level
WARN Designates potentially harmful situations
ERROR Designates error events that might still allow the application to continue running
FATAL Designates very severe error events that will presumably lead the application to abort

The default (global) log level in the configuration is WARN. All messages of level WARN and more severe (ERROR, FATAL) are written to the rolling log file. The easiest way to get finer log messages is to change it like this

默认的日志级别是warn (它会记录warn , error 和 fatal 这三个级别的消息) 最方便的方法修改日志finder级别像下面一行是把warn 改成了 debug

log4j.rootCategory=DEBUG, stdout, R

These detailed log messages took much file space and time and therefore should only be enabled globally in order to analyze problems.

这些详细的日志消息将会占用大量的文件空间和一些cpu运算时间, 因此 它们必须能够保持统一的格式才好去分析问题。

It is possible to configure the logging more fine grained by using categories. Within the default configuration there are some examples:


# with these we'll not get inundated when switching to DEBUG


If the global level is switched to DEBUG, these definitions override the setting with WARN for certain areas and therefore keep the file a little bit smaller. Learn more about the concept of categories in theShort introduction to log4j.

如果全局的日志级别切换成了DEBUG ,那么这些以包名定义的配置 仍然会使用WARN级别。这样将会使生成的日志文件小很多。(说的就是 以局部的配置为优先 即在局部采用warn 其它的还用全局的DEBUG级别)想要学习更多的分类概念请参考Short introduction to log4j.

Format for log messages


The format of each line within a log file is controlled by a pattern. For the RollingFileAppender in the default configuration it looks like this

日志的每一行信息显示格式 都会被pattern所控制,下面是RollingFileAppender生成的日志所采用的格式

log4j.appender.R.layout.ConversionPattern=[%d{HH:mm:ss}] %p [%c] - %m%n

Some examples lines within the log file, formatted with the pattern "[%d{HH:mm:ss}] %p [%c] - %m%n" are:


[12:29:03] WARN [org.apache.directory.server.core.DefaultDirectoryService]
    - You didn't change the admin password of directory service instance 'default'.
    Please update the admin password as soon as possible to prevent a possible security breach.
[12:29:05] INFO [org.apache.directory.server.jndi.ServerContextFactory]
    - Successful bind of an LDAP Service (636) is complete.
[12:29:05] INFO [org.apache.directory.server.Service] - server: started in 6750 milliseconds

The pattern uses the following conversion characters:


Character Output
%d Date of the logging event in the given format. like "12:29:05" for %d 时间格式
%p Priority (level) of the logging event, like "INFO" or "WARN" 日志级别
%c Category of the logging event, like "org.apache.directory.server.Service" 日志分类
%m Application supplied message associated with the logging event
%n Platform dependent line separator 换行符

The javadoc of log4j contains a table with all valid %-characters and their meaning.

javadoc of log4j 里面包含了所有的格式化字符含义

Simple adjust the pattern in the log4j.properties file to get the log format of your choice, for instance


log4j.appender.R.layout.ConversionPattern=[%d{dd.MM.yyyy HH:mm:ss}] %p: %c{1}.%M() - %m%n

[29.12.2006 13:50:44] INFO: ServerContextFactory.startLDAP0() 
    - Successful bind of an LDAP Service (636) is complete.
[29.12.2006 13:50:44] INFO: Service.init() - server: started in 3016 milliseconds
** Warning**"Generating caller location information like with %M or %L is extremely slow. Its use should be avoided unless execution speed is not an issue." (from the log4j documentation)

警告 使用%M or %L pattern 会拖慢服务器的运行速度,请谨慎使用.

Advanced log4j configuration


You can take advantage of other features of log4j as well, such as other appenders like the daily rolling file appender. And you can configure logging to make it easier for you to view the messages with tools like Log Factor 5 orChainsaw.

你也可以利用log4j的一些其它特性,例如别的appenders 像daily rolling file appender (一天记录一个日志文件) 和 你也可以通过配置使你更容易的查看消息利用工具Factor 5 orChainsaw.

Learn more about log4j and related tools at its homepage.

想学习更多的关于log4j的知识和工具 请访问它的官方主页 homepage.

Example configurations


The following example could be used to log all incoming search, add, delete, modify and moddn requests:

下面的例子可以被用于记录所有的 对apache ds 的查询 添加 删除和修改请求


Log settings of the Windows daemon process

apache ds 在 win 环境下的日志配置

After installation on Windows, you have the option to configure the ApacheDS Windows Service (you can do this later as well). If you do so, one option pane is dedicated to logging:

Windows service properties

You can adjust the logging level and a log path. Note that this is for the daemon only. The server itself is configured as described above.


ApacheDS 2.0__Basic User Guide 1.4.5 - Enable and disable anonymous access (基础用户指导手册)

  • huangshouxiang
  • huangshouxiang
  • 2016-05-30 17:40:03
  • 201


  • 2015年11月05日 15:40
  • 30.92MB
  • 下载

A Guide to Convolutional Neural Networks for Computer Vision(计算机视觉-卷积网络指导手册)

  • 2018年03月02日 13:33
  • 6.28MB
  • 下载


  • 2014年04月25日 15:22
  • 217KB
  • 下载


1) 下载ApacheDS 地址为: http://directory.apache.org 2) 在ApacheDS 安装完成后要启动ApacheDS服务。路径如下:计算机— 管理—服务–...
  • danruoshui315
  • danruoshui315
  • 2015-08-27 10:37:02
  • 2136

DBArtisan 8.5 用户 手册 User Guide

  • 2009年04月03日 10:25
  • 12.78MB
  • 下载

DBArtisan 8.6 用户手册

  • 2009年04月03日 10:12
  • 11.88MB
  • 下载

AM335x U-Boot User's Guide 中文手册

AM335x U-Boot User's Guide   /****************************************************************** ...
  • luhao806
  • luhao806
  • 2012-09-14 16:39:23
  • 4850


随着 linux的不断普及,很多的朋友把redhat安装到了自己的计算机上,从此也就开始了对redhat的摸索。我在这里也把我的一点心得体会告诉大家,希望对大家有所帮助。apache 的安装通常来说,...
  • songdongchang
  • songdongchang
  • 2007-04-13 22:23:00
  • 299

iGrafx IDEF0 2011 User Guide

  • 2011年05月26日 15:05
  • 523KB
  • 下载
    访问量: 707
    积分: 37
    排名: 192万+