Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8610407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:07:19+00:00 2026-06-12T04:07:19+00:00

I am trying to get an logger and add a specific appender to it.

  • 0

I am trying to get an logger and add a specific appender to it. My code is very simple but I am not sure how to get this working.

val loggerInstance = LoggerFactory.getLogger("FOO.class")
var fileAppender =  new FileAppender()
// fileAppender .setFile , sietPattern etc..the parameters i want
loggerInstance.addAppender(fileAppender) 

I get an error here

Multiple markers at this line
- type mismatch; found : ch.qos.logback.core.FileAppender[Nothing] required: 
     ch.qos.logback.core.Appender[ch.qos.logback.classic.spi.ILoggingEvent] Note: Nothing <: 
     ch.qos.logback.classic.spi.ILoggingEvent, but Java-defined trait Appender is invariant in type E. You may wish to investigate a 
     wildcard type such as `_ <: ch.qos.logback.classic.spi.ILoggingEvent`. (SLS 3.2.10)
    - Line breakpoint:loggerchange [line: 76] - addAppender

I have no clue what this error means and how to solve it. Can someone help me?

EDIT :

I tried to do what was told by drexin. I was not able to extend the interface and define the functions . There were only three functions , setName,getName, and doAppend. i am not sure as how to define these functions. Meanwhile i tried something and removed the errors. Please look into the code and let me know if what i am doing makes any sense .

val encoder = new PatternLayoutEncoder()
encoder2.setContext(context)
encoder2.setPattern("%msg%")    
fileAppender.setAppend(true)
fileAppender.setContext(context)
fileAppender.setEncoder(encoder2.asInstanceOf[Encoder[Nothing]])

loggerInstance.asInstanceOf[Logger].addAppender(fileAppender
.asInstanceOf[Appender[ILoggingEvent]])

I know using asInstanceOf is not a smart way of coding but for now i want to make this work . When i execute this code i am getting the file in which i want to log but there is no logs inside it. I have checked for level errors , but that’s not the case. i believe there is something wrong with encoder/layout. I am not sure how to fix it. Can someone show me how to either extend the class and apply the functions or what is wrong in this new code .

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T04:07:20+00:00Added an answer on June 12, 2026 at 4:07 am

    The FileAppender has a type parameter class FileAppender[E], but you instantiate it without providing such a parameter, so scala decides to put Nothing in as type. addAppender expects an appender of type Appender[ILoggingEvent], that is what the error says. What you have to do now, is to either use an existing, or create your own subclass of ILoggingEvent and provide it as type param:

    class MyLoggingEvent extends ILoggingEvent {
      // implement ALL the methods
    }
    
    val fileAppender = new FileAppender[MyLoggingEvent]()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to get this expression to work, can someone look at it and tell
I'm trying to get an optional lookahead but am having problems where as soon
I am trying to get the mercurial revision number/id (it's a hash not a
I'm trying to debug why I get this error: Error occurred while sending a
I am trying to get my head round node.js... I am very happy with
I'm trying to get a POJO starting on startup within my Weld/Seam3 application but
I've been trying for longer than I'd like to admit to get JSTL working
I'm trying to setup the new Bonsai ElasticSearch heroku add-on, but until now I
So i am trying get 2 div-containers which both should contain centered text (Both
I'm trying get the visible portion of UIImage from an UIImageView . UIImageView takes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.