Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

SLF4J LOGGER working in Eclipse but not binging correctly to JForex client
 Post subject: SLF4J LOGGER working in Eclipse but not binging correctly to JForex client Post rating: 0   New post Posted: Sun 29 Apr, 2012, 13:26 

User rating: 2
Joined: Sun 26 Jun, 2011, 07:05
Posts: 15
Location: Australia, Melbourne
Hi team,

I copied an example of yours in the support forum comment below to try to get LOGGER output working in JForex client not just Eclipse:
https://www.fxmarketplace.ch/swiss/english/forex/jforex/forum/viewtopic.php?f=61&t=25597&view=unread

I run on OSX, so my compile code is the following (with my username replaced with "XXX" in the path):

import com.dukascopy.api.*;
 
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
 
@RequiresFullAccess
@Library("/Users/XXX/JForex/strategies/files/log4j-over-slf4j-1.6.4.jar:/Users/XXX/JForex/strategies/files/slf4j-api-1.6.4.jar")


public class LoggingTests implements IStrategy
{
 
   public void onStart(IContext context) throws JFException
   {
      Logger logger = LoggerFactory.getLogger(LoggingTests.class);
      logger.info("log test");
     
      context.getConsole().getOut().println("println");
 
   }
   public void onTick(Instrument instrument, ITick tick) throws JFException {}
   public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {}
   public void onMessage(IMessage message) throws JFException {}
   public void onAccount(IAccount account) throws JFException {}
   public void onStop() throws JFException {}
}


I have downloaded version 1.6.4 of the SLF4J libraries and placed the files referenced in the correct locations, so the above code compiles correctly in JForex.

Unfortunately strategy this only outputs the println() not the logger.info(). I can not see the logger output in JForex at all - not in the Messages tab, not in the Historical Test tab when backtested nor in the strategy tab when running the strategy.

Please advise what I am doing wrong.



thanks,
C


 
 Post subject: Re: SLF4J LOGGER working in Eclipse but not binging correctly to JForex client Post rating: 0   New post Posted: Mon 30 Apr, 2012, 08:40 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Could you please check what you receive both in Messages tab and Java console by changing the onStart method to:
    public void onStart(IContext context) throws JFException {
        Logger logger = LoggerFactory.getLogger(LoggingTests.class);
        context.getConsole().getOut().println(String.format("info=%s, error=%s", logger.isInfoEnabled(), logger.isErrorEnabled()));
        logger.info("info log test");
        logger.error("error log test");
    }


 
 Post subject: Re: SLF4J LOGGER working in Eclipse but not binging correctly to JForex client Post rating: 0   New post Posted: Wed 02 May, 2012, 08:40 

User rating: 2
Joined: Sun 26 Jun, 2011, 07:05
Posts: 15
Location: Australia, Melbourne
Hi support,

After replacing the onStart() method with the code you suggested, I received the following output when running the Historical Tester:


07:45:17 info=true, error=true


... but once again, only the output from the println() was visible, not the outputs from logger.error() or logger.info()


Any suggestions?

I will try the same sample code & SLF4J JAR files in linux and windows to verify the behaviour.



cheers,
Christian


 
 Post subject: Re: SLF4J LOGGER working in Eclipse but not binging correctly to JForex client Post rating: 0   New post Posted: Wed 02 May, 2012, 09:32 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Did you check the outputs on Java console? See:
viewtopic.php?f=81&t=39073


 
 Post subject: Re: SLF4J LOGGER working in Eclipse but not binging correctly to JForex client Post rating: 0   New post Posted: Tue 15 May, 2012, 07:02 

User rating: 2
Joined: Sun 26 Jun, 2011, 07:05
Posts: 15
Location: Australia, Melbourne
Hi Support,

In Windows I see the LOGGER output calls in the java console.
In Linux (when I start JForex or my custom application from a terminal/console) I see the LOGGER output calls in the terminal/console.

Even though I would have preferred to see the outputs in the JForex platform, this is good enough for me to monitor.



thanks for your help,
Christian


 

Jump to:  

  © 1998-2025 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com