Annotation Type Log


  • @InterceptorBinding
    @Documented
    @Target({TYPE,METHOD})
    @Retention(RUNTIME)
    @Inherited
    public @interface Log
    An annotation applicable to methods and types for which you wish to trace the invocation of the method(s). Only DI managed bean are taken in charge by the processor of this annotation.

    With this annotation, for each invocation of the method, by default, one log record will be generated with either a default message or the one specified with this annotation. The default message is generated from the simple class name, the name of the invoked method, and the values of the arguments passed to the method (if any). With the dualRecord() property you can indicate to write two log records instead of one for each invocation of the method. In this case the first one will be written before the method execution and the second one just after its completion. The last record will have along the message (the default or the specified one) the time spent by the execution of the method.

    A custom message or a pattern of a custom message can be specified with the message() property. In the case of a pattern, it has to satisfy the templating rules of a MessageFormat pattern. With a pattern, the values of the method parameters can be injected into the resulting message: {0} designates the first parameter, {1} the second one, and so one.

    Author:
    mmoquillon
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      boolean dualRecord
      Is the message (the default or the custom one) concerned by a dual record?
      org.silverpeas.kernel.logging.Level level
      The logging level to use with this annotation.
      String message
      A message to record into the log.
    • Element Detail

      • message

        String message
        A message to record into the log. If not set, a default message will be computed from the class simple name, the name and the value of the parameters of the invoked method. If set, this message will be used instead and only one log record will be written before the method invocation (no log record after the invocation). In order to write the message with the method parameters, a pattern of such a message can be provided here. For doing, the pattern has to follow the pattern rules of MessageFormat. Hence, for example, a pattern like "Process instance {1} for {0}" expects to be injected into the resulting message the value of the second parameter of the method followed by the value of the first one.
        Returns:
        a message or a pattern of a message to record or an empty string to use the default message.
        Default:
        ""
      • dualRecord

        boolean dualRecord
        Is the message (the default or the custom one) concerned by a dual record? A dual record consists to split the message in two records: one before the method execution and the second after its completion. In other words, to write the message two times, wrapping the execution of the method. In this case, the time spent by the execution of the method will be indicated along the second record. For a simple record, the message will be written only before the execution of the method.
        Returns:
        true if the message is concerned by a dual record into the log: one before the method execution and the second after its completion. Otherwise, only one message will be written and this before the execution of the method. In the case of a dual record, the time spent by the method execution will be indicated along with the second record.
        Default:
        false
      • level

        org.silverpeas.kernel.logging.Level level
        The logging level to use with this annotation. By default Level.INFO.
        Returns:
        the level used when logging a message at each annotated method invocation.
        Default:
        org.silverpeas.kernel.logging.Level.INFO