问题
I'm using a non-.NET worker role, configured by setting the ProgramEntryPoint in the service definition. That means that there is no .NET code in my application, which is written in Java and Python.
When I run my worker role locally, I can open the Windows Azure Compute Emulator application and look at the standard output and error of my worker process.
When I remote desktop into my Azure instance, I don't know where to get that same information. Where do I find standard output and error?
回答1:
To directly answer the question above:
<ProgramEntryPoint commandLine="run.bat >> app.log 2>&1" ... "/>
When you run above command in compute emulator, you are asking to redirect the command shell output to the same location where run.bat is located. That's it. When you launch your worker role in compute emulator, it is started from the location inside CSX folder and the app.log is created there.
Now if you take the exact same code and deploy on Windows Azure, so when "run.bat >> app.log" will be executed, the app.log file will be created in the same directly where your run.bat is located. You can find it at E:\Approot\ after your RDP your Azure instance.
Above method is correct but the strategy is NOT RIGHT. This is because:
- The logs will not persist in Azure VM in Azure VM is recycled
- You would need to RDP to Azure VM to check, (What if you have 100 instances, will you RDP to each one to get the log?)
The best strategy would be if these custom logs which are created by 3rd party applications, are transferred directly to Azure Storage.
In any scenario where there is custom application i.e. java.exe, php.exe, python etc, I suggest to create the log file directly at "Local Storage" Folder and then initialize Azure Diagnostics in Worker Role (WorkerRole.cs) to export these custom log files directly from Azure VM to your Azure Blob storage.
How to create custom logs on local storage is described here
回答2:
A simple strategy is to redirect the output of your program to a file:
<ProgramEntryPoint commandLine="run.bat >> app.log 2>&1" ... "/>
The &
is important to keep XML parsers happy.
Be aware that after doing this, you won't be able to see the logs in the Windows Azure Compute Emulator anymore. To look at the logs, open PowerShell and type:
cd E:\approot # or myapp.csx\roles\WorkerRole\approot if running locally
cat -wait app.log
Also be aware that this strategy requires you to remote desktop into an Azure instance to see the logs. This might be a great way to get started quickly, if anything.
来源:https://stackoverflow.com/questions/10827388/where-do-i-find-my-non-net-roles-logs-when-using-remote-desktop