https://github.com/ahmednawras/log4erl/blob/master/API.txt

NOTE:
=====
Please be informed that the API below as of now is not stable and any of the functions/parameters below
may be changed without prior notice.

Furthermore, you can find appenders and their configurations in 'Appenders_API.txt' file included in release.

**> log4erl:conf(File) -> ok | {error, E}
File :: string()

File is the name of the configuration file. Please check CONFIGURATION.txt for the format of this file.

**> log4erl:add_logger(Name) -> ok | {error, E}
Name :: atom() name of the logger

Example:
log4erl:add_logger(chat_logger)
This will create a new logger with name 'chat_logger"

**> log4erl:change_log_level(Level) -> ok
log4erl:change_log_level(Logger, Level) -> ok
Level::atom() = {all, debug, info, error, warn, fatal, none}
Logger::atom()

This will change log level for default logger or named logger to the level
specified.

Example:
log4erl:change_log_level(info). %% This will change level of default logger to info
log4erl:change_log_level(test_log, warn) %% This will change level of test_log logger to warn

**> log4erl:change_level(Appender, Level) -> ok
log4erl:change_level(Logger, Appender, Level) -> ok
Logger :: atom()
Appender :: atom()
Level :: atom()

@since version 0.8.4

This will change log level for a specific appender, as opposed to change_log_level/2,3 which changes
level for all appenders in a logger.

Example:
log4erl:change_level(appender1, all).

**> log4erl:change_format(Appender, Format) -> ok
log4erl:change_format(Logger, Appender, Format) -> ok
Appender :: atom()
Logger :: atom()
Format :: string()

@since version 0.8.3

This will change the output format to the specified Format. Format is a pattern string similar to
PatternLayout in Log4j. patterns is an arbitrary string with specifiers (proceeded by '%').
Possible specifiers are below:
d - output date (2008-3-7)
j - output date (2008-03-07)
t - time (2:13:9)
T - time (02:28:01.811637)
y - year in YY format (08)
Y - year in YYYY format (2008)
M - month (2)
b - short name of month (Feb)
B - long name of month (February)
D - day
h - hour
m - minute
s - second
i - milli-seconds
l - the actual log message
I - ISO format with universal GMT time (equivilant to "%jT%TZ").
S - ISO format with local time and time zone offset
Z - timezone (+04:00)
L - log level
n - new line
% - the percentage sign (%)

Example:
log4erl:change_format(file1, "%j %T [%L] %l%n").
Will result in the following output (on log4erl:warn("hello"))

27-10-2008 15:28:59,98621 [warn] hello

**> log4erl:log(Level, Log) -> ok
Level :: atom()
Log :: string()

This will log the text Log to the default logger with level Level.

Example:
log4erl:log(warn, "Hello there").
log4erl:log(test_level, "Hello there").

**> log4erl:log(Level, Log, Data) -> ok
Level :: atom()
Log :: string()
Data :: list()

This will log the text Log to the default logger with level Level and
will use Data to format the log text.

Example:
log4erl:log(info, "received message ~p", [Msg]).

**> log4erl:log(Logger, Level, Log, Data) -> ok
Logger :: atom()
Level :: atom()
Log :: string()
Data :: list()

This will log the (Log, Data) to Logger with level Level

Example:
log4erl:log(chat_log, debug, "user entered chat text: ~p", [Chat]).

**> log4erl:Level(Log) -> ok
log4erl:Level(Log, Data) -> ok
log4erl:Level(Logger, Data) -> ok
log4erl:Level(Logger, Log, Data) -> ok

Level :: warn | info | error | fatal | debug
Logger :: atom()
Log :: string()
Data :: list()

Exmaple:
log4erl:info("This is an info msg").
log4erl:warn("Received error ~p",[Msg]).
log4erl:fatal(chat_log, "exception occured").
log4erl:debug(chat_log, "message received is ~p", [Msg]).
log4erl:error("Error").

**> log4erl:error_logger_handler() -> ok
log4erl:error_logger_handler(Mappings) -> ok
where
Mappings :: [Mapping]
Mapping :: {Elevels, level}
ELevels :: error | info_msg | warning_msg | error_report | info_report | warning_report

Mappings basically is a list of mapping between error_logger log levels and log4erl log levels.
Currently, report messages are not handled by this error_logger handler. The default Mappings are:
{error=error, info_msg=info, warning_msg=warn,
error_report=error, info_report=info,
warning_report=warn}

Example:
log4erl:error_logger_handler([{error, fatal}, {info_msg, info}]).

which treats all error messages coming from error_logger as fatal and all info_msg
messages coming from error_logger as info.

log4erl API的更多相关文章

  1. log4erl Configuration

    https://github.com/ahmednawras/log4erl/blob/master/CONFIGURATION.txt Configuration Guide: ========== ...

  2. Log4erl

    http://developerworks.github.io/2011/05/16/erlang-use-log4erl/ Erlang 使用Log4erl all = debug < inf ...

  3. 干货来袭-整套完整安全的API接口解决方案

    在各种手机APP泛滥的现在,背后都有同样泛滥的API接口在支撑,其中鱼龙混杂,直接裸奔的WEB API大量存在,安全性令人堪优 在以前WEB API概念没有很普及的时候,都采用自已定义的接口和结构,对 ...

  4. 12306官方火车票Api接口

    2017,现在已进入春运期间,真的是一票难求,深有体会.各种购票抢票软件应运而生,也有购买加速包提高抢票几率,可以理解为变相的黄牛.对于技术人员,虽然写一个抢票软件还是比较难的,但是还是简单看看123 ...

  5. 几个有趣的WEB设备API(二)

    浏览器和设备之间还有很多有趣的接口, 1.屏幕朝向接口 浏览器有两种方法来监听屏幕朝向,看是横屏还是竖屏. (1)使用css媒体查询的方法 /* 竖屏 */ @media screen and (or ...

  6. html5 canvas常用api总结(三)--图像变换API

    canvas的图像变换api,可以帮助我们更加方便的绘画出一些酷炫的效果,也可以用来制作动画.接下来将总结一下canvas的变换方法,文末有一个例子来更加深刻的了解和利用这几个api. 1.画布旋转a ...

  7. JavaScript 对数据处理的5个API

    JavaScript对数据处理包括向上取整.向下取整.四舍五入.固定精度和固定长度5种方式,分别对应ceil,floor,round,toFixed,toPrecision等5个API,本文将对这5个 ...

  8. ES5对Array增强的9个API

    为了更方便的对Array进行操作,ES5规范在Array的原型上新增了9个方法,分别是forEach.filter.map.reduce.reduceRight.some.every.indexOf ...

  9. javascript的api设计原则

    前言 本篇博文来自一次公司内部的前端分享,从多个方面讨论了在设计接口时遵循的原则,总共包含了七个大块.系卤煮自己总结的一些经验和教训.本篇博文同时也参考了其他一些文章,相关地址会在后面贴出来.很难做到 ...

随机推荐

  1. 学习笔记:Vue——自定义指令

    在Vue2.0中,代码复用和抽象的主要形式是组件.然鹅,有的情况下,你仍然需要对普通DOM元素进行底层操作,这时候就会用到自定义指令. 1.举个聚焦输入框的例子,全局注册focus指令 Vue.dir ...

  2. 【CS Round #46 (Div. 1.5) B】Letters Deque

    [链接]h在这里写链接 [题意] 让你把一个正方形A竖直或水平翻转. 问你翻转一次能不能把A翻转成B [题解] 有说一定要恰好为1次. 并不是说A和B相同就一定不行. [错的次数] 2 [反思] 自己 ...

  3. 【AtCoder Regular Contest 082】Derangement

    [链接]点击打开链接 [题意] 在这里写题意 [题解] 贪心. 连续一块的p[i]==i的话,对答案的贡献就应该为(这个连续块的长度+1)/2; 长度为1的也正确. (也即两两相邻的互换位置.) [错 ...

  4. C/S与B/S架构比较

    一C/S 1.C/S概念 C/S是Client/Server的缩写.服务器通常采用高性能的PC.工作站或小型机,并采用大型数据库系统,如Oracle.Sybase.Informix或 SQL Serv ...

  5. Android 解决RecyclerView删除Item导致位置错乱的问题

    RecyclerView的刷新分为内容变化和结构变化,结构变化比如remove和insert等并不会导致viewholder的更新,所以有时候我们使用 notifyItemRemoved(positi ...

  6. Nginx TCP代理

    nginx 在1.9.0 版本发布以前如果要想做到基于TCP的代理及负载均衡需要通过打名为nginx_tcp_proxy_module的第三方patch来实现,该模块的代码托管在github上 网址: ...

  7. ViewPage第二课为ViewPage加入标题

    在第一课 学前准备:掌握ViewPage第一课http://blog.csdn.net/wei_chong_chong/article/details/50468832 为ViewPage加入标题: ...

  8. android蓝牙主动发起配对实例

    package cn.madfinger.core; import java.io.IOException; import java.lang.reflect.Method; import java. ...

  9. VSX(翻译)Moving Code Blocks Among Code Regions using VS 2010 Extensions

    Moving Code Blocks Among Code Regions using VS 2010 Extensions (翻译)使用VS 2010 扩展性将代码块移至Region区域中 Down ...

  10. java并发之生产者消费者模型

    生产者和消费者模型是操作系统中经典的同步问题.该问题最早由Dijkstra提出,用以演示它提出的信号量机制. 经典的生产者和消费者模型的描写叙述是:有一群生产者进程在生产产品.并将这些产品提供给消费者 ...