Forum

Author Topic: Saving log to a specified location with log_path  (Read 3720 times)

Dark_Corvid

  • Newbie
  • *
  • Posts: 6
    • View Profile
Saving log to a specified location with log_path
« on: July 11, 2019, 05:30:11 AM »
In my script, I enabled the log with
Code: [Select]
Metashape.Application.Settings(log_enable=True) This generates a log file as expected.

However, when I try to set the log to a save location as specified in the API
Code: [Select]
Metashape.Application.Settings(log_path="C:/somelocation") the log is not saved where specified.

Any help would be appreciated.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: Saving log to a specified location with log_path
« Reply #1 on: July 11, 2019, 11:12:07 AM »
Hello Dark_Corvid,

Please try the following:

Code: [Select]
Metashape.app.settings.log_path = "C:/somelocation/log.txt"
Best regards,
Alexey Pasumansky,
Agisoft LLC

Dark_Corvid

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Saving log to a specified location with log_path
« Reply #2 on: July 11, 2019, 10:44:21 PM »
I did as you suggested but found I had to also change
Code: [Select]
Metashape.Application.Settings(log_enable=True) to
Code: [Select]
Metashape.app.settings.log_enable = True then it all worked.

Thank you!

Christina K

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Saving log to a specified location with log_path
« Reply #3 on: July 18, 2019, 02:46:49 PM »
We are running Metashape from Python in the background without any visual console or information. Consequently, I would like to enable the logging, to be able to see what happened if something went wrong.

I currently have this lines (as suggested in the previous posts) right after importing Metashape.

Code: [Select]
Metashape.app.settings.log_enable = True
# Metashape.Application.Settings(log_enable=True)
# Run specific
Metashape.app.settings.log_path = os.path.join(work_dir, "console_log.txt")


But the log is not saved. Both variations of log_enable do not work and I am out of ideas.

The line where we define the log_path seems to work because when I open metashape and go to preferences I can see the correct path. The box "write to log" is also checked. When running a project in the normal GUI the log is saved to the correct location. It just does not seem to work from Python.

Thanks in advance!

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: Saving log to a specified location with log_path
« Reply #4 on: July 23, 2019, 05:59:33 PM »
Hello Christina,

For headless scripts I suggest to use the OS re-directing feature.
Best regards,
Alexey Pasumansky,
Agisoft LLC

Christina K

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Saving log to a specified location with log_path
« Reply #5 on: July 25, 2019, 12:03:03 AM »
Thank you for your response.

We are indeed running the script headless. But I am unsure what you mean with "OS re-directing feature and I could not really find anything about it on Google.

I am asking this question because:

We are currently running multiple agisoft projects after each other from a queue. What happened one of the datasets gave an error in the Dense Cloud generations: Zero Resolution. The error was not properly handled by the script. Processing crashed/was stuck for more than one day.

I need a way to access the log (or maybe there is another way) to be able after each processing step to check for critical errors such as zero resolutions. If one is found we can stop processing of that dataset and continue with the next one.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: Saving log to a specified location with log_path
« Reply #6 on: July 25, 2019, 12:32:49 PM »
Hello Christina,

For example, if you are using Windows, you can re-direct the log output in the following way:
Code: [Select]
metashape.exe -r "D:/script.py" > "D:/log.txt" 2>&1It will save both common and error output streams to the same file.

As for the error specifics, "Zero Resolution" could mean that the bounding box does not include the area of interest. If you are optimizing the alignment prior to the dense cloud generation, I can suggest to use resetRegion() function after optimization is completed.
Best regards,
Alexey Pasumansky,
Agisoft LLC