Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jul 25 00:22

    darkfrog26 on slf4j-api-1.7.31

    (compare)

  • Jul 25 00:22
    darkfrog26 closed #201
  • Jul 25 00:22
    darkfrog26 commented #201
  • Jul 25 00:22
    darkfrog26 opened #210
  • Jul 25 00:22

    darkfrog26 on slf4j-api-1.7.32

    Update slf4j-api to 1.7.32 (compare)

  • Jul 25 00:22
    darkfrog26 opened #209
  • Jul 25 00:22

    darkfrog26 on profig-3.2.6

    Update profig to 3.2.6 (compare)

  • Jul 25 00:22

    darkfrog26 on fabric-parse-1.0.8

    (compare)

  • Jul 25 00:22
    darkfrog26 closed #196
  • Jul 25 00:22
    darkfrog26 commented #196
  • Jul 25 00:22
    darkfrog26 opened #208
  • Jul 25 00:22

    darkfrog26 on fabric-parse-1.0.11

    Update fabric-parse to 1.0.11 (compare)

  • Jul 18 00:23

    darkfrog26 on sbt-1.5.4

    (compare)

  • Jul 18 00:23
    darkfrog26 closed #200
  • Jul 18 00:23
    darkfrog26 commented #200
  • Jul 18 00:23
    darkfrog26 opened #207
  • Jul 18 00:22

    darkfrog26 on sbt-1.5.5

    Update sbt to 1.5.5 (compare)

  • Jul 11 00:22
    darkfrog26 opened #206
  • Jul 11 00:22

    darkfrog26 on scala-collection-compat-2.5.0

    Update scala-collection-compat … (compare)

  • Jul 11 00:22
    darkfrog26 opened #205
Andreas Joseph Krogh
@andreak
Ok
Matt Hicks
@darkfrog26
...and bug fixes. :o
Matt Hicks
@darkfrog26
@andreak you'll need 3.5.3 since Sonatype had some strange glitch last night and won't let me publish 3.5.2
it should be sync'd by now
Andreas Joseph Krogh
@andreak
Rock!
Andreas Joseph Krogh
@andreak
Same with 3.5.3; When the log-file exists (created over a month ago) the file is appended to instead of rolled.
Matt Hicks
@darkfrog26
hmmm
@andreak do you want to take a look at the logic and see if you can see where my mistake is?
Andreas Joseph Krogh
@andreak

@darkfrog26 Hm, I think I've found something useful...
This config results in working rolling:

object LoggerInit {

    val mdcFormatter: Formatter = formatter"$dateFull [$threadName] [${mdc(Constants.LOG_MDC_USERNAME_KEY)}] [${mdc(Constants.LOG_MDC_REQUEST_KEY)}] $levelColoredPaddedRight ${green(position)} - $message"

    val dailyRolling = rolling("-" % daily("-"))

    def apply(moduleName: String) {

        val fileWriterDebug = FileWriter(
            Paths.get(System.getProperty("user.home"), "visena", "logs", moduleName) / ("visena-debug" % dailyRolling % ".log")
        ).flushAsync

        val debugHandler = LogHandler(
            minimumLevel = Some(Level.Debug)
            , writer = fileWriterDebug
            , formatter = mdcFormatter
            , modifiers =
                List(select(
                    className("io.milton.http.StandardFilter")
                ).include(filterLevel >= Level.Error)
                )
        )

        Logger.root
            .clearHandlers()
            .clearModifiers()
            .withMinimumLevel(Level.Info)
            .withHandler(debugHandler)
            .replace()

    }
}

// This config works with rolling:
object VisenaImapServer {
    val moduleName = "imap-server"
    scribe.Logger("james.imapserver")
        .orphan()
        .clearHandlers()
        .clearModifiers()
        .withHandler(minimumLevel = Some(Level.Trace)
            , writer = FileWriter(
                Paths.get(System.getProperty("user.home"), "visena", "logs", moduleName) / ("james-trace" % LoggerInit.dailyRolling % ".log")
            ).flushAsync
            , formatter = mdcFormatter
        )
        .replace()

        // ...other stuff
}

Meaning the logger james.imapserver "rolls".

But this does not:

object VisenaImapServer {

    val moduleName = "imap-server"
    LoggerInit(moduleName)
}

Meaning visena-debug.log in $HOME/visena/logs/imap-server/visena-debug.log does ''not'' roll.

Matt Hicks
@darkfrog26
apart from the lack of the modifier, I don't see much difference
oh, you're also not modifying the root logger, just creating your own
Andreas Joseph Krogh
@andreak
I suspect that val dailyRolling in LoggerInit should be a def?
Matt Hicks
@darkfrog26
no, that shouldn't be necessary because the underlying objects have methods called, not evaluated
Andreas Joseph Krogh
@andreak
Ah, I didn't get it then...:-)
At least the james-trace.log rolls fine but visena-debug.log does not....
Matt Hicks
@darkfrog26
you can try making dailyRolling into a method and see if it changes anything...it shouldn't but it's possible that's the problem
Andreas Joseph Krogh
@andreak
...it doesn't...
Matt Hicks
@darkfrog26
try changing to your custom logger instead of root and see if that resolves it
Andreas Joseph Krogh
@andreak

Well, the logging code is called from e.g.:

trait VisenaLoggable extends LoggerSupport {
    @transient
    val myLogger = this

    override def log[M](record: LogRecord[M]): Unit = Logger(record.className).log(record)
}

package com.visena.foo
class MyClass extends VisenaLoggable {
      def doStuff(): Unit = {
          debug(s"Doing stuff")
      }
}

...and many other packages and that wouldn't work with a "static" (non-root) logger would it?

Andreas Joseph Krogh
@andreak

Hm, initializing the logger like this:

    LoggerInit("email-import")

With this config:

object LoggerInit {

    val mdcFormatter: Formatter = formatter"$dateFull [$threadName] [${mdc(Constants.LOG_MDC_USERNAME_KEY)}] [${mdc(Constants.LOG_MDC_REQUEST_KEY)}] $levelColoredPaddedRight ${green(position)} - $message"

    val dailyRolling = rolling("-" % daily("-"))

    def apply(moduleName: String) {
        val consoleHandler = LogHandler(minimumLevel = Some(Level.Error), writer = ConsoleWriter, formatter = mdcFormatter)

        val fileWriterDebug = FileWriter(
            Paths.get(System.getProperty("user.home"), "visena", "logs", moduleName) / ("visena-debug" % dailyRolling % ".log")
        ).flushAsync

        val debugHandler = LogHandler(
            minimumLevel = Some(Level.Debug)
            , writer = fileWriterDebug
            , formatter = mdcFormatter
            , modifiers =
                List(select(
                    className("io.milton.http.StandardFilter")
                ).include(filterLevel >= Level.Error)
                )
        )

        Logger.root
            .clearHandlers()
            .clearModifiers()
            .withMinimumLevel(Level.Info)
            .withHandler(consoleHandler)
            .withHandler(debugHandler)
            .replace()

    }
}

it works...

Matt Hicks
@darkfrog26
what did you change?
Andreas Joseph Krogh
@andreak
I left out some config, trying to isolate...
With this config it doesn't:
object LoggerInit {

    val mdcFormatter: Formatter = formatter"$dateFull [$threadName] [${mdc(Constants.LOG_MDC_USERNAME_KEY)}] [${mdc(Constants.LOG_MDC_REQUEST_KEY)}] $levelColoredPaddedRight ${green(position)} - $message"

    val dailyRolling = rolling("-" % daily("-"))

    def apply(moduleName: String) {
        val consoleHandler = LogHandler(minimumLevel = Some(Level.Error), writer = ConsoleWriter, formatter = mdcFormatter)

        val fileWriterDebug = FileWriter(
            Paths.get(System.getProperty("user.home"), "visena", "logs", moduleName) / ("visena-debug" % dailyRolling % ".log")
        ).flushAsync

        val debugHandler = LogHandler(
            minimumLevel = Some(Level.Debug)
            , writer = fileWriterDebug
            , formatter = mdcFormatter
            , modifiers =
                List(select(
                    className("io.milton.http.StandardFilter")
                ).include(filterLevel >= Level.Error)
                )
        )

        Logger.root
            .clearHandlers()
            .clearModifiers()
            .withMinimumLevel(Level.Info)
            .withHandler(consoleHandler)
            .withHandler(debugHandler)
            .replace()

        Logger("no.officenet").withModifier(boosted(Level.Debug, Level.Info)).replace()
        Logger("com.visena").withModifier(boosted(Level.Debug, Level.Info)).replace()

        scribe.Logger("SERVICETIMELOGGER")
            .orphan()
            .clearHandlers()
            .clearModifiers()
            .withHandler(minimumLevel = Some(Level.Info)
                , writer = FileWriter(
                    Paths.get(System.getProperty("user.home"), "visena", "logs", moduleName) / ("visena-performance" % dailyRolling % ".log")
                ).flushAsync
                , formatter = mdcFormatter
            )
            .replace()

        scribe.Logger("AspectJ Weaver")
            .orphan()
            .clearHandlers()
            .clearModifiers()
            .withHandler(minimumLevel = Some(Level.Info)
                , writer = FileWriter(
                    Paths.get(System.getProperty("user.home"), "visena", "logs", moduleName) / ("aspectj" % dailyRolling % ".log")
                ).flushAsync

                , formatter = mdcFormatter
            )
            .replace()

    }
}
Matt Hicks
@darkfrog26
Can you create a ticket for me with some sample code I can recreate this with?
Andreas Joseph Krogh
@andreak
Yup, trying to isolate more first...
Andreas Joseph Krogh
@andreak

Hm, this works:

object LoggerInit {

    val mdcFormatter: Formatter = formatter"$dateFull [$threadName] [${mdc(Constants.LOG_MDC_USERNAME_KEY)}] [${mdc(Constants.LOG_MDC_REQUEST_KEY)}] $levelColoredPaddedRight ${green(position)} - $message"

    val dailyRolling = rolling("-" % daily("-"))

    def apply(moduleName: String) {
        val consoleHandler = LogHandler(minimumLevel = Some(Level.Error), writer = ConsoleWriter, formatter = mdcFormatter)

        val fileWriterDebug = FileWriter(
            Paths.get(System.getProperty("user.home"), "visena", "logs", moduleName) / ("visena-debug" % dailyRolling % ".log")
        ).flushAsync

        val debugHandler = LogHandler(
            minimumLevel = Some(Level.Debug)
            , writer = fileWriterDebug
            , formatter = mdcFormatter
            , modifiers =
                List(select(
                    className("io.milton.http.StandardFilter")
                ).include(filterLevel >= Level.Error)
                )
        )

        Logger.root
            .clearHandlers()
            .clearModifiers()
            .withMinimumLevel(Level.Info)
            .withHandler(consoleHandler)
            .withHandler(debugHandler)
            .replace()

        Logger("no.officenet").withModifier(boosted(Level.Debug, Level.Info)).replace()
        Logger("com.visena").withModifier(boosted(Level.Debug, Level.Info)).replace()

    }
}

This doesn't (added the scribe.Logger("AspectJ Weaver")):

object LoggerInit {

    val mdcFormatter: Formatter = formatter"$dateFull [$threadName] [${mdc(Constants.LOG_MDC_USERNAME_KEY)}] [${mdc(Constants.LOG_MDC_REQUEST_KEY)}] $levelColoredPaddedRight ${green(position)} - $message"

    val dailyRolling = rolling("-" % daily("-"))

    def apply(moduleName: String) {
        val consoleHandler = LogHandler(minimumLevel = Some(Level.Error), writer = ConsoleWriter, formatter = mdcFormatter)

        val fileWriterDebug = FileWriter(
            Paths.get(System.getProperty("user.home"), "visena", "logs", moduleName) / ("visena-debug" % dailyRolling % ".log")
        ).flushAsync

        val debugHandler = LogHandler(
            minimumLevel = Some(Level.Debug)
            , writer = fileWriterDebug
            , formatter = mdcFormatter
            , modifiers =
                List(select(
                    className("io.milton.http.StandardFilter")
                ).include(filterLevel >= Level.Error)
                )
        )

        Logger.root
            .clearHandlers()
            .clearModifiers()
            .withMinimumLevel(Level.Info)
            .withHandler(consoleHandler)
            .withHandler(debugHandler)
            .replace()

        Logger("no.officenet").withModifier(boosted(Level.Debug, Level.Info)).replace()
        Logger("com.visena").withModifier(boosted(Level.Debug, Level.Info)).replace()

        scribe.Logger("AspectJ Weaver")
            .orphan()
            .clearHandlers()
            .clearModifiers()
            .withHandler(minimumLevel = Some(Level.Info)
                , writer = FileWriter(
                    Paths.get(System.getProperty("user.home"), "visena", "logs", moduleName) / ("aspectj" % dailyRolling % ".log")
                ).flushAsync
                , formatter = mdcFormatter
            )
            .replace()

    }
}

I've tested issuing:

touch -d "2 days ago" visena-debug.log

To make the log "2 days old" and see if logging rolls on app-start.

Andreas Joseph Krogh
@andreak
@darkfrog26 I've created an issue here: outr/scribe#184
Can you please test and see if you get to reproduce it?
Matt Hicks
@darkfrog26
Yeah...I'll try to get a look at it soon...I've got a ton of things I need to get through this week though, so it might take a while.
Andreas Joseph Krogh
@andreak
No problem, just curious to see if you get to reproduce it.
Matt Hicks
@darkfrog26
@andreak I just responded to your ticket...let me know if you have questions
Andreas Joseph Krogh
@andreak
@darkfrog26 Responded now
Matt Hicks
@darkfrog26
3.5.4 is released
Andreas Joseph Krogh
@andreak
Rock!
Andreas Joseph Krogh
@andreak
Just a thought; Should log-frameworks which supports rolling perform rolling upon startup? I for one think it would be convenient if Scribe rolled "old logs" upon startup and not wait for the 1st log-entry to perform rolling.
...it would help keeping the log-directory "clean"
Matt Hicks
@darkfrog26
that's probably a good idea, but I tried to make all the "work" that Scribe does lazy to avoid unnecessary impact if no logging occurs
Andreas Joseph Krogh
@andreak
I see. However, "auto-rolling" might have 2 modes:
  1. myConfig.rollOnStartup <- Automatically roll on startup, if necessary
  2. myConfig.autoRoll <- In addition to performing rolling on startup, also roll on "roll-boundry". By this I mean "if dailyRolling then roll every day even if no log-statements are issued". This way it's up to the developer to decide which behavour he wants, "super lazy" og "tight".
This is by no means a dealbreaker for me, only nice-to-have.
Maatary
@Maatary
hi @darkfrog26, wondering: Is there any builtin support to measure and log the elapsed of a method ?
Maatary
@Maatary
do you have any example on how to that ? what's the set up ? it seem mdc need to be involved ? i'm no familiar with it
some pointer woukd help
Matt Hicks
@darkfrog26
@Maatary there are actually a few ways to accomplish this, but the easiest way is using elapsed
scribe.elapsed {
  scribe.info("Any logging within elapsed will include MDC data for the amount of time elapsed")
  myMethod()
  scribe.info("myMethod completed successfully")
}
@andreak sorry, I thought I had sent you a response, but just realized I never did. I would be fine with something like this, but it would probably be better as a configuration option in FileWriter. If you'd be interested in submitted a PR to add this I'd be happy to integrate it.
Maatary
@Maatary

I just tested something like that

scribe.elapsed {
    scribe.info("started run(fun2)")
    println(run(fun(2)))
    scribe.info("run(fun2) was successful")
  }

and got

2021.05.16 10:12:40:132 [main      ] [INFO ] IO.IOBasic.IOBasic.IOBasic:184 - started run(fun2) (elapsed: 0.14s)
64
2021.05.16 10:12:40:270 [main      ] [INFO ] IO.IOBasic.IOBasic.IOBasic:186 - run(fun2) was successful (elapsed: 0.17s)

Process finished with exit code 0

Not sure how to interpret what i am seeing.
Alo note sure to understand this sentence

Any logging within elapsed will include MDC data for the amount of time elapsed"
Can you maybe explain a bit further or else point me to what i should read to understand what's going on and how to interpret the result i am seeing

Matt Hicks
@darkfrog26
the timer starts at the beginning of elapsed and increases as time goes by. For example, in your usecase, it took 30ms to run fun(2)
Maatary
@Maatary
I see Thanks
Matt Hicks
@darkfrog26
Scribe 3.5.5 is released with Scala 3.0.0 support