Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
new-relic-logger-for-python
Advanced tools
Push logs into New Relic using standard python logger asynchronously.
This library enables the standard python logger to send its logs to New Relic using an async strategy. Note: These logs are linked to the application only in the context of a web transaction.
Configure the APM agent according to the documentation. A newrelic.ini
should be generated.
By default (unless NEW_RELIC_LOGGER_AUTOIMPORT_DISABLE is True), to enable the python logging module, include this line in your file.
import newrelic_logger
if auto import is disabled, it must be instantiated in the code
from newrelic_logger import NewRelicLogger
NewRelicLogger(...)
NewRelicLogger constructor receives the following optional arguments:
Name | Type | Description |
---|---|---|
app_id | int | The app id for the newrelic APM |
app_name | str | The app name for the newrelic APM |
license_key | str | The license_key for comunicating with the new relic api |
region | str | The region for newrelic, either "US" or "EU" |
log_level | ENUM | The numeric level of the logging event (one of DEBUG, INFO etc.) |
Optionally, some arguments can be configured by environment variables. These are:
Name | Description |
---|---|
NEW_RELIC_LOGGER_AUTOIMPORT_DISABLE | Disable the auto import functionality |
NEW_RELIC_APP_ID | The app id for the newrelic APM |
NEW_RELIC_APP_NAME | he app name for the newrelic APM |
NEW_RELIC_LICENSE_KEY | The license_key for comunicating with the new relic api |
NEW_RELIC_REGION | The region for newrelic, either "US" or "EU" |
Just use the normal python logger, for example, to send an info message:
import logging
logging.info("This is an info message")
Note: It could be useful to replace the python print function inside your main application to use the logger.info implementation. The following code shows how its done.
import logging
logger = logging.getLogger()
print = logger.info
print("message") # same as logger.info("message")
Run the application using the new relic agent either by using the admin script integration, or the manual integration, as mentioned in the documentation. For example, for the admin script:
NEW_RELIC_CONFIG_FILE=newrelic.ini newrelic-admin run-program YOUR_COMMAND_OPTIONS
and for the manual integration:
import newrelic.agent
newrelic.agent.initialize('/some/path/newrelic.ini')
FAQs
Push logs into New Relic using standard python logger asynchronously.
We found that new-relic-logger-for-python demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.