Is there a way to set through code the location where logs occur when requests are made to the Python API?
Thanks in advance for any help you can provide.
Hi,
To simplify this, you can use set_log_path() function:
ek.set_log_path("c:\Temp\eikon")
You'll find logs in this directory.
Eikon Data APIs library for Python uses standard Python library named "logging" to create the log. You can get the logger created by Eikon Data APIs library for Python with
import logginglogger = logging.getLogger('pyeikon')
And then you can add a FileHandler to pyeikon logger to provide output to a file, e.g.
lh = logging.FileHandler('C:\Temp\pyeikon.log')logger.addHandler(lh)
I may be wrong, but it sounds like you're not very familiar with the logging library or how the logs are usually created in Python. If this is the case, I suggest you go through some tutorials, of which there's an abundance on the Internet, to learn about the logging library and how to configure the output for the logs produced by Python libraries.
Hi Alex, thanks a lot! And yes, you guessed right about my knowledge gap for the whole subject of logging folders, but your advice was super useful!
For any code that I produce that imports eikon I'll have to do this, hopefully this will solve the issue I'm facing in which some folder logs are being created in undesirable places. I'll let you know in the upcoming days how it went.
Thank you Pierre. This approach is different than the one Alex suggested, regardless, it didn't produce the same output. I created a dummy folder to test this one (on c:\desktop\dummy_logs) and the contents were empty after I ran a test. The version Alex did allocated a .txt file with the logs. So I'm not quite sure what went wrong with your approach. Did I do something wrong? Should I used a similar path?
I noticed this post uses this in combination with ek.set_log_level. @Alex Putkov.1 appears there too btw. What I'm not sure of is the integer he plugs in to get a different type of log. According to the guide, there are only 8 options available through the logger. I plugged in 2 different integers as input, 1 and 10. The only virtual difference was that one of the files had a line that was for TRACE. Why is that? I would like to know. Btw, that option in that post works great as well.