logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Remko Popma (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (LOG4J2-770) Add method addOnLogging() in Logger interface
Date Mon, 11 Aug 2014 14:09:11 GMT

     [ https://issues.apache.org/jira/browse/LOG4J2-770?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Remko Popma resolved LOG4J2-770.
--------------------------------

    Resolution: Not a Problem

Okay, thanks for understanding. I will resolve this issue as "Not a problem", and if you have
further questions please give us a shout on the log4j-user mailing list or raise another Jira,
and we will see what we can do.

> Add method addOnLogging() in Logger interface
> ---------------------------------------------
>
>                 Key: LOG4J2-770
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-770
>             Project: Log4j 2
>          Issue Type: New Feature
>          Components: API, Core
>            Reporter: Krzysztof Szewczyk
>
> It would be useful to add method addOnLogging or similar that would be enable the addition
action during logging.
> In my work copy I did something like that:
> - I created:
> {code:title=OnLogging.java|borderStyle=solid}
> public interface OnLogging{
>     public void onLogging(Level level, Object message, Throwable ex);
> }
> {code}
> - I added to interface Logger method:
> {code:title=org.apache.logging.log4j.Logger.java|borderStyle=solid}
> public void addOnLogging(OnLogging ol);
> {code}
> - in Logger implementations I added:
> {code:title=org.apache.logging.log4j.core.Logger.java|borderStyle=solid}
> private List<OnLogging> onLoggingList;
> public addOnLogging(OnLogging ol){
>     onLoggingList.add(ol);
> }
> //edit method
> public void logMessage(final String fqcn, final Level level, final Marker marker, final
Message msg, final Throwable throwable) {
> // ....
>     for(OnLogging ol : onLoggingList) {
>         ol.onLogging(level, msg, t);
>     }
> }
> {code}
> - and finish - example usecase:
> {code:title=Example.java|borderStyle=solid}
> private Label label = new ....;
> private Logger l = ....;
> public void init() {
>     l.addOnLogging((Level level, Object o, Throwable thrwbl) -> {
>             if (level == Level.WARN) {
>                 label.setColor("yellow");
>                 label.setText(o.toString());
>             } else if (level == Level.ERROR) {
>                 label.setColor("red");
>                 label.setText(o.toString());
>             } else if (level == Level.FATAL) {
>                 label.setColor("brown");
>                 label.setText(o.toString());
>                 ErrorDialog.show(o.toString, thrwbl);
>                 Platform.exit();
>             }
>         });
>     l.warn("This is warning on my label");
> }
> {code}
> I needed it because I wanted to bind logs with my gui - on logging action I update some
control to give user some information.
> I hope that you will consider it a useful feature



--
This message was sent by Atlassian JIRA
(v6.2#6252)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message