Skip to content

Commit f7e4e8e

Browse files
committed
javascript logging etc
1 parent f455d59 commit f7e4e8e

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

articles/cognitive-services/Speech-Service/how-to-use-logging.md

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,38 +18,45 @@ Logging to file is an optional feature for the Speech SDK. During development lo
1818

1919
## Sample
2020

21-
The log file name is specified on a configuration object. Taking the `SpeechConfig` as an example and assuming that you have created an instance called `config`:
21+
The log file name is specified on a configuration object. Taking the `SpeechConfig` as an example and assuming that you have created an instance called `speechConfig`:
2222

2323
```csharp
24-
config.SetProperty(PropertyId.Speech_LogFilename, "LogfilePathAndName");
24+
speechConfig.SetProperty(PropertyId.Speech_LogFilename, "LogfilePathAndName");
2525
```
2626

2727
```java
28-
config.setProperty(PropertyId.Speech_LogFilename, "LogfilePathAndName");
28+
speechConfig.setProperty(PropertyId.Speech_LogFilename, "LogfilePathAndName");
2929
```
3030

3131
```C++
32-
config->SetProperty(PropertyId::Speech_LogFilename, "LogfilePathAndName");
32+
speechConfig->SetProperty(PropertyId::Speech_LogFilename, "LogfilePathAndName");
3333
```
3434
3535
```Python
36-
config.set_property(speechsdk.PropertyId.Speech_LogFilename, "LogfilePathAndName")
36+
speech_config.set_property(speechsdk.PropertyId.Speech_LogFilename, "LogfilePathAndName")
3737
```
3838

3939
```objc
40-
[config setPropertyTo:@"LogfilePathAndName" byId:SPXSpeechLogFilename];
40+
[speechConfig setPropertyTo:@"LogfilePathAndName" byId:SPXSpeechLogFilename];
4141
```
4242
4343
```go
4444
import ("github.com/Microsoft/cognitive-services-speech-sdk-go/common")
4545
46-
config.SetProperty(common.SpeechLogFilename, "LogfilePathAndName")
46+
speechConfig.SetProperty(common.SpeechLogFilename, "LogfilePathAndName")
4747
```
4848

49-
You can create a recognizer from the config object. This will enable logging for all recognizers.
49+
You can create a recognizer from the configuration object. This will enable logging for all recognizers.
5050

5151
> [!NOTE]
52-
> If you create a `SpeechSynthesizer` from the config object, it will not enable logging. If logging is enabled though, you will also receive diagnostics from the `SpeechSynthesizer`.
52+
> If you create a `SpeechSynthesizer` from the configuration object, it will not enable logging. If logging is enabled though, you will also receive diagnostics from the `SpeechSynthesizer`.
53+
54+
JavaScript is an exception where the logging is enabled via SDK diagnostics as shown in the following code snippet:
55+
56+
```javascript
57+
sdk.Diagnostics.SetLoggingLevel(sdk.LogLevel.Debug);
58+
sdk.Diagnostics.SetLogOutputPath("LogfilePathAndName");
59+
```
5360

5461
## Create a log file on different platforms
5562

@@ -62,15 +69,15 @@ UWP applications need to be places log files in one of the application data loca
6269
```csharp
6370
StorageFolder storageFolder = ApplicationData.Current.LocalFolder;
6471
StorageFile logFile = await storageFolder.CreateFileAsync("logfile.txt", CreationCollisionOption.ReplaceExisting);
65-
config.SetProperty(PropertyId.Speech_LogFilename, logFile.Path);
72+
speechConfig.SetProperty(PropertyId.Speech_LogFilename, logFile.Path);
6673
```
6774

6875
Within a Unity UWP application, a log file can be created using the application persistent data path folder as follows:
6976

7077
```csharp
7178
#if ENABLE_WINMD_SUPPORT
7279
string logFile = Application.persistentDataPath + "/logFile.txt";
73-
config.SetProperty(PropertyId.Speech_LogFilename, logFile);
80+
speechConfig.SetProperty(PropertyId.Speech_LogFilename, logFile);
7481
#endif
7582
```
7683
For more about file access permissions in UWP applications, see [File access permissions](/windows/uwp/files/file-access-permissions).
@@ -82,7 +89,7 @@ You can save a log file to either internal storage, external storage, or the cac
8289
```java
8390
File dir = context.getExternalFilesDir(null);
8491
File logFile = new File(dir, "logfile.txt");
85-
config.setProperty(PropertyId.Speech_LogFilename, logFile.getAbsolutePath());
92+
speechConfig.setProperty(PropertyId.Speech_LogFilename, logFile.getAbsolutePath());
8693
```
8794

8895
The code above will save a log file to the external storage in the root of an application-specific directory. A user can access the file with the file manager (usually in `Android/data/ApplicationName/logfile.txt`). The file will be deleted when the application is uninstalled.
@@ -101,7 +108,7 @@ Within a Unity Android application, the log file can be created using the applic
101108

102109
```csharp
103110
string logFile = Application.persistentDataPath + "/logFile.txt";
104-
config.SetProperty(PropertyId.Speech_LogFilename, logFile);
111+
speechConfig.SetProperty(PropertyId.Speech_LogFilename, logFile);
105112
```
106113
In addition, you need to also set write permission in your Unity Player settings for Android to "External (SDCard)". The log will be written
107114
to a directory you can get using a tool such as AndroidStudio Device File Explorer. The exact directory path may vary between Android devices,

0 commit comments

Comments
 (0)