Skip to content

Commit 3ec40e1

Browse files
TophrC-ddcswatt
andauthored
Tophr c dd/aas docs update (#29111)
Co-authored-by: cswatt <[email protected]>
1 parent 120e027 commit 3ec40e1

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

content/en/serverless/azure_app_services/azure_app_services_container.md

+12-5
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,17 @@ To set up logging in your application, see [Node.js Log Collection][3]. To set u
198198

199199
### Application settings
200200

201-
In your **App settings** in Azure, set the following environment variables:
201+
In your **App settings** in Azure, set the following environment variables on both your main container and the sidecar container. Alternatively, set these variables on your main container and enable the **Allow access to all app settings** option.
202+
203+
{{< img src="serverless/azure_app_service/app_settings.png" alt="In Azure, an Environment Variables section. An 'Allow access to all app settings' option is enabled with a checkbox." >}}
202204

203205
- `DD_API_KEY`: Your [Datadog API key][3]
204206
- `DD_SERVICE`: How you want to tag your service. For example, `sidecar-azure`
205207
- `DD_ENV`: How you want to tag your env. For example, `prod`
206208
- `DD_SERVERLESS_LOG_PATH`: Where you write your logs. For example, `/home/LogFiles/*.log` or `/home/LogFiles/myapp/*.log`
209+
- `DD_AAS_INSTANCE_LOGGING_ENABLED`: When `true`, log collection is automatically configured for an additional file path: `/home/LogFiles/*$COMPUTERNAME*.log`
210+
211+
<div class="alert alert-info">If your application has multiple instances, make sure that your application's log filename includes the <code>$COMPUTERNAME</code> variable. This ensures that log tailing does not create duplicated logs from multiple instances reading the same file.</div>
207212

208213
<details open>
209214
<summary>
@@ -239,7 +244,7 @@ const logger = createLogger({
239244
level: 'info',
240245
exitOnError: false,
241246
format: format.json(),
242-
transports: [new transports.File({ filename: `/home/LogFiles/app.log`}),
247+
transports: [new transports.File({ filename: `/home/LogFiles/app-${process.env.COMPUTERNAME}.log`}),
243248
],
244249
});
245250

@@ -269,6 +274,7 @@ app.listen(port);
269274
```python
270275
from flask import Flask, Response
271276
from datadog import initialize, statsd
277+
import os
272278
import ddtrace
273279
import logging
274280

@@ -277,7 +283,7 @@ ddtrace.patch(logging=True)
277283
FORMAT = ('%(asctime)s %(levelname)s [%(name)s] [%(filename)s:%(lineno)d] '
278284
'[dd.service=%(dd.service)s dd.env=%(dd.env)s dd.version=%(dd.version)s dd.trace_id=%(dd.trace_id)s dd.span_id=%(dd.span_id)s] '
279285
'- %(message)s')
280-
logging.basicConfig(filename='/home/LogFiles/app.log', format=FORMAT)
286+
logging.basicConfig(filename=f'/home/LogFiles/app-{os.getenv(COMPUTERNAME)}.log', format=FORMAT)
281287
log = logging.getLogger(__name__)
282288
log.level = logging.INFO
283289

@@ -377,7 +383,8 @@ func main() {
377383
if err != nil {
378384
panic(err)
379385
}
380-
logFilePath := filepath.Join(logDir, "app.log")
386+
387+
logFilePath := filepath.Join(logDir, fmt.Sprintf("app-%s.log", os.Getenv("COMPUTERNAME")))
381388
log.Println("Saving logs in ", logFilePath)
382389
logFileLocal, err := os.OpenFile(logFilePath, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644)
383390
if err != nil {
@@ -422,7 +429,7 @@ $statsd = new DogStatsd(
422429
$log = new logger('datadog');
423430
$formatter = new JsonFormatter();
424431

425-
$stream = new StreamHandler('/home/LogFiles/app.log', Logger::DEBUG);
432+
$stream = new StreamHandler('/home/LogFiles/app-'.getenv("COMPUTERNAME").'.log', Logger::DEBUG);
426433
$stream->setFormatter($formatter);
427434

428435
$log->pushHandler($stream);
Loading

0 commit comments

Comments
 (0)