8000 GitHub · Where software is built
[go: up one dir, main page]

Skip to content
Log splits by '\n' in the message when using StructuredLogHandler to write logs in Cloud Run #318
Closed
@kwsz

Description

@kwsz

Thanks for stopping by to let us know something could be better!

PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.

Please run down the following list and make sure you've tried the usual "quick fixes":

If you are still having issues, please be sure to include as much information as possible:

Environment details

  • OS type and version: Cloud Run
  • Python version: 3.7
  • pip version:
  • google-cloud-logging version: 2.4.0

Steps to reproduce

  1. Set up StructuredLogHandler to write logs
  2. Write logs containing a '\n'
  3. Build the image and run it on Cloud Run
  4. See the Cloud Logging dashboard

Code example

def prep_structured_logging():
    logger = logging.getLogger()
    logger.setLevel(logging.INFO)
    # Delete unused handlers
    logger.handlers = []

    client = google.cloud.logging.Client()
    cloud_handler = StructuredLogHandler()
    setup_logging(cloud_handler)


@app.route('/test_structured', methods=['POST'])
def test_structured():
    prep_structured_logging()

    text = request.values.get('text', 'logging text')

    logging.error(text + "\n" + text)

    return "Success!"

Stack trace

Making sure to follow these steps will guarantee the quickest resolution possible.

Thanks!

Metadata

Metadata

Assignees

Labels

api: loggingIssues related to the googleapis/python-logging API.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0