You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Bruce Brouwer (JIRA)" <ji...@apache.org> on 2014/03/22 01:58:43 UTC

[jira] [Commented] (LOG4J2-33) Support Annotations

    [ https://issues.apache.org/jira/browse/LOG4J2-33?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13943808#comment-13943808 ] 

Bruce Brouwer commented on LOG4J2-33:
-------------------------------------

You should check out [Project Lombok|http://projectlombok.org/]. It uses Java's built in annotation processing features to make your code look like this:

{code}
@Log
public class LogExample {
  public static void main(String... args) {
    log.error("Something's wrong here");
  }
}
{code}

And no, that code did not neglect to extend another class, nor did it neglect to define the log field. You could probably take the concepts from Lombok to do stuff like this as well:
{code}
public class LogExample {
  @LogEntryExit
  public void doStuff() {
    // do stuff
  }
}
{code}

Basically, it uses byte code manipulation to make this all work. From what I can tell, there is no need to setup anything special with javac or maven; it just works. It looks like there are some issues with some IDEs, which Project Lombok has solved. I haven't used it yet myself, but it might be fun to try it out in Log4j 2 (maybe after 2.0 is released)

> Support Annotations
> -------------------
>
>                 Key: LOG4J2-33
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-33
>             Project: Log4j 2
>          Issue Type: New Feature
>          Components: API
>    Affects Versions: 2.0-rc2
>            Reporter: Ralph Goers
>             Fix For: 0.1, 2.0-rc2
>
>         Attachments: 0001-Add-Loggable.patch
>
>
> The Log4j API should support using annotations as provided in Java 6 so applications can use them instead of calls to logger APIs. This is especially useful for entering & exiting type of events, but could be used wherever annotations are allowed.



--
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